Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-32244

Environment variable for current branch

    Details

    • Similar Issues:

      Description

      Original reporter A. Klitzing

      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.

        Attachments

          Issue Links

            Activity

            mjdetullio Matthew DeTullio created issue -
            mjdetullio Matthew DeTullio made changes -
            Field Original Value New Value
            Description 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.
            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.
            mjdetullio Matthew DeTullio made changes -
            Description 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.
            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.
            larsmeynberg Lars Meynberg made changes -
            Link This issue is related to JENKINS-30252 [ JENKINS-30252 ]
            mjdetullio Matthew DeTullio made changes -
            Link This issue is duplicated by JENKINS-32241 [ JENKINS-32241 ]
            mjdetullio Matthew DeTullio made changes -
            Link This issue is related to JENKINS-32234 [ JENKINS-32234 ]
            mjdetullio Matthew DeTullio made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 167829 ] JNJira + In-Review [ 198287 ]

              People

              • Assignee:
                mjdetullio Matthew DeTullio
                Reporter:
                mjdetullio Matthew DeTullio
              • Votes:
                2 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: