Reputation: 10294
Via entry point file
I invoke a php script from jenkins, using the "Execute shell" section -
php entry.php branch_name_${branch_name} deployment_group_${deployment_group} rollback_${rollback} last_successful_revision_${last_successful_revision} sanity_check_duration_start_time_delay_sec_${sanity_check_duration_start_time_delay_sec} sanity_check_duration_end_time_delay_sec_${sanity_check_duration_end_time_delay_sec}
I tried accessing the jenkins build number there, but it was not available -
$build_number = exec(${BUILD_NUMBER});
file_put_contents('/home/jenkins/deployment_beta/phing/new_test_sandeepan.txt', "\n Build number is ".$build_number, FILE_APPEND);
Log lin in that file shows -
Build number is
Via phing xml file
I also tried accessing it in a phing xml file -
<appspecFileModifications buildName="${BUILD_NUMBER}" />
This xml file is invoked via the above mentioned entry file (php script), like this -
$last_output = exec("phing -q -Dbranch_name=".$branchName, $output);
I checked other questions like - How to use jenkins to declare BUILD_NUMBER environment variable in gradle? Jenkins - How to access BUILD_NUMBER environment variable
Upvotes: 0
Views: 1061
Reputation: 596
With Phing you would be able to get environment variables with a prefixed env.
<appspecFileModifications buildName="${env.BUILD_NUMBER}" />
All variables from $_SERVER
are available in this way.
Upvotes: 0