-
Bug
-
Resolution: Unresolved
-
Major
-
None
Context: I'm trying to create a parameterized job chain for our branches.
Version info:
Jenkins 1.450
Git 1.1.15
build-name-setter 1.3
parametrized trigger 2.12
1) Set the git branch to */master and in advanced, select branching strategy = inverse
2) Set the build name (using plugin) to #${BUILD_NUMBER}.${GIT_BRANCH}
3) In the build, use shell to execute: echo ${BUILD_BRANCH}
4) Push a change into a branch in git then manually start the build in Jenkins
Result:
The build string is set correctly to the branch used in step#4, but the echo in step #3 incorrectly says origin/master. Note, that the wrong GIT_BRANCH is also sent in my parameterized trigger.
The setting for GIT_BRANCH is correct at all times when Default choosing strategy is selected.
[JENKINS-12655] GIT_BRANCH is incorrect in build steps when branch choosing strategy is set to inverse (but it is correct in build name macro)
Description |
Original:
Context: I'm trying to create a parameterized job chain for our branches. 1) Set the git branch to */master and in advanced, select branching strategy = inverse 2) Set the build name (using plugin) to #${BUILD_NUMBER}.${GIT_BRANCH} 3) In the build, use shell to execute: echo ${BUILD_BRANCH} 4) Push a change into a branch in git then manually start the build in Jenkins Result: The build string is set correctly to the branch used in step#4, but the echo in step #3 incorrectly says origin/master. Note, that the wrong GIT_BRANCH is also sent in my parameterized trigger. The setting for GIT_BRANCH is correct at all times when Default choosing strategy is selected. |
New:
Context: I'm trying to create a parameterized job chain for our branches. Version info: Jenkins 1.450 Git 1.1.15 build-name-setter 1.3 parametrized trigger 2.12 1) Set the git branch to */master and in advanced, select branching strategy = inverse 2) Set the build name (using plugin) to #${BUILD_NUMBER}.${GIT_BRANCH} 3) In the build, use shell to execute: echo ${BUILD_BRANCH} 4) Push a change into a branch in git then manually start the build in Jenkins Result: The build string is set correctly to the branch used in step#4, but the echo in step #3 incorrectly says origin/master. Note, that the wrong GIT_BRANCH is also sent in my parameterized trigger. The setting for GIT_BRANCH is correct at all times when Default choosing strategy is selected. |
Workflow | Original: JNJira [ 143110 ] | New: JNJira + In-Review [ 175814 ] |
Assignee | Original: Andrew Bayer [ abayer ] |
note: Step#3 above should say echo ${GIT_BRANCH}
Here is the build log. As you can see, it knows the GIT_BRANCH at one point, (at the "commencing build" line),
then loses that information in the build script, when it gets echoed.
Started by user rmorgenstein
Building remotely on volt4c in workspace /var/voltdb/jenkins/workspace/xtest-jenkins
Deleting project workspace... done
Checkout:xtest-jenkins / /var/voltdb/jenkins/workspace/xtest-jenkins - hudson.remoting.Channel@11c0f73a:volt4c
Using strategy: Inverse
Last Built Revision: Revision d4da8cf9aa3456030142fd56034d87d2f8d22de7 (origin/voltdb-0.6)
Checkout:voltdb / /var/voltdb/jenkins/workspace/xtest-jenkins/voltdb - hudson.remoting.LocalChannel@630f83c9
Cloning the remote Git repository
Cloning repository origin
Fetching upstream changes from git@github.com:VoltDB/voltdb.git
Cleaning workspace
Seen branch in repository origin/ElClient
Seen branch in repository origin/HEAD
Seen branch in repository origin/build-tests
...
Seen branch in repository origin/voltcore-integration
Seen branch in repository origin/voltdb-0.6
Seen branch in repository origin/voltdb-0.9
Seen branch in repository origin/voltdb-1.0
...
Commencing build of Revision 5af56f1a105129ae24895c3e6434294cf736ebbe (origin/voltdb-0.9)
Checking out Revision 5af56f1a105129ae24895c3e6434294cf736ebbe (origin/voltdb-0.9)
Cleaning workspace
No change to record in branch origin/voltdb-0.9
[xtest-jenkins] $ /bin/sh -xe /tmp/hudson7808160474733240525.sh
+ echo 'GIT_BRANCH = origin/master'
GIT_BRANCH = origin/master
+ echo 'GIT_COMMIT = 5af56f1a105129ae24895c3e6434294cf736ebbe'
GIT_COMMIT = 5af56f1a105129ae24895c3e6434294cf736ebbe
+ echo 'BUILD_TAG = jenkins-xtest-jenkins-8'
BUILD_TAG = jenkins-xtest-jenkins-8
Finished: SUCCESS