-
Improvement
-
Resolution: Fixed
-
Minor
-
None
Original reporter misery
I need to know the current branch in generated job (see conditional step) but there is no $BRANCH variable or something like this I can use. $JOB_NAME does not contain only "branch name".
Please add a $CURRENT_BRANCH or something like this.
As a work-around I used Envinject plugin with the following groovy script.
def jobName = currentJob.getName() return [BRANCH: "${jobName}"]
It's weird that currentJob.getName() works instead of $JOB_NAME.
- is duplicated by
-
JENKINS-32241 Job does not resolve {GIT_BRANCH} token on first job run. Need a branch env name for build
-
- Closed
-
- is related to
-
JENKINS-30252 Provide easy access to git branch name in multibranch workflow scripts
-
- Resolved
-
-
JENKINS-32234 Use branch-api
-
- Resolved
-
[JENKINS-32244] Environment variable for current branch
Description |
Original:
I need to know the current branch in generated job (see conditional step) but there is no $BRANCH variable or something like this I can use. $JOB_NAME does not contain only "branch name". Please add a $CURRENT_BRANCH or something like this. As a work-around I used Envinject plugin with the following groovy script. ``` def jobName = currentJob.getName() return [BRANCH: "${jobName}"] ``` It's weird that currentJob.getName() works instead of $JOB_NAME. |
New:
Original reporter [~misery] I need to know the current branch in generated job (see conditional step) but there is no $BRANCH variable or something like this I can use. $JOB_NAME does not contain only "branch name". Please add a $CURRENT_BRANCH or something like this. As a work-around I used Envinject plugin with the following groovy script. ``` def jobName = currentJob.getName() return [BRANCH: "${jobName}"] ``` It's weird that currentJob.getName() works instead of $JOB_NAME. |
Description |
Original:
Original reporter [~misery] I need to know the current branch in generated job (see conditional step) but there is no $BRANCH variable or something like this I can use. $JOB_NAME does not contain only "branch name". Please add a $CURRENT_BRANCH or something like this. As a work-around I used Envinject plugin with the following groovy script. ``` def jobName = currentJob.getName() return [BRANCH: "${jobName}"] ``` It's weird that currentJob.getName() works instead of $JOB_NAME. |
New:
Original reporter [~misery] I need to know the current branch in generated job (see conditional step) but there is no $BRANCH variable or something like this I can use. $JOB_NAME does not contain only "branch name". Please add a $CURRENT_BRANCH or something like this. As a work-around I used Envinject plugin with the following groovy script. {code} def jobName = currentJob.getName() return [BRANCH: "${jobName}"] {code} It's weird that currentJob.getName() works instead of $JOB_NAME. |
Link |
New:
This issue is related to |
Link |
New:
This issue is duplicated by |
Link |
New:
This issue is related to |
Resolution | New: Fixed [ 1 ] | |
Status | Original: Open [ 1 ] | New: Resolved [ 5 ] |
Workflow | Original: JNJira [ 167829 ] | New: JNJira + In-Review [ 198287 ] |
I read about
{env.BRANCH_NAME}should do the trick. Does that work for you?