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

Pipeline jobs do not have access to env.BRANCH

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Duplicate
    • gitlab-plugin, pipeline
    • None
    • Jenkins ver. 2.63
      GitLab plugin 1.4.5

    Description

      So, I've already had to abandon multibranch pipelines because they don't get the gitlab variables that I need for my build. Now, I'm working on a regular pipeline and it doesn't have access to the global BRANCH variable.

      So, I can't do pleasant stage conditions like this

      when {
          branch 'master'
      }
      

      I have to write gnarlier conditions

      when {
          environment name: 'gitlabBranch', value: 'master'
      }
      

      Attachments

        Issue Links

          Activity

            anthonymastrean Anthony Mastrean created issue -
            anthonymastrean Anthony Mastrean made changes -
            Field Original Value New Value
            Description So, I've already had to abandon multibranch pipelines because they don't get the gitlab variables that I need for my build. Now, I'm working on a regular pipeline and it doesn't have access to the global BRANCH variable.

             !image-2017-06-29-14-23-14-076.png!

            So, I can't do stage conditions like this

            {code}
            when {
                branch 'master'
            }
            {code}

            I have to write gnarly conditionals

            {code}
            if ${env.gitlabBranch} == 'master' {
                ...
            }
            {code}

            And I'm not even sure if that works in the declarative pipeline syntax yet!
            So, I've already had to abandon multibranch pipelines because they don't get the gitlab variables that I need for my build. Now, I'm working on a regular pipeline and it doesn't have access to the global BRANCH variable.

             !image-2017-06-29-14-23-14-076.png!

            So, I can't do pleasant stage conditions like this

            {code}
            when {
                branch 'master'
            }
            {code}

            I have to write gnarlier conditions

            {code}
            when {
                environment name: 'gitlabBranch', value: 'master'
            }
            {code}

            And I'm not even sure if that works in the declarative pipeline syntax yet!
            anthonymastrean Anthony Mastrean made changes -
            Description So, I've already had to abandon multibranch pipelines because they don't get the gitlab variables that I need for my build. Now, I'm working on a regular pipeline and it doesn't have access to the global BRANCH variable.

             !image-2017-06-29-14-23-14-076.png!

            So, I can't do pleasant stage conditions like this

            {code}
            when {
                branch 'master'
            }
            {code}

            I have to write gnarlier conditions

            {code}
            when {
                environment name: 'gitlabBranch', value: 'master'
            }
            {code}

            And I'm not even sure if that works in the declarative pipeline syntax yet!
            So, I've already had to abandon multibranch pipelines because they don't get the gitlab variables that I need for my build. Now, I'm working on a regular pipeline and it doesn't have access to the global BRANCH variable.

             !image-2017-06-29-14-23-14-076.png!

            So, I can't do pleasant stage conditions like this

            {code}
            when {
                branch 'master'
            }
            {code}

            I have to write gnarlier conditions

            {code}
            when {
                environment name: 'gitlabBranch', value: 'master'
            }
            {code}
            abayer Andrew Bayer made changes -
            Link This issue duplicates JENKINS-45198 [ JENKINS-45198 ]
            abayer Andrew Bayer made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Resolved [ 5 ]
            owenmehegan Owen Mehegan made changes -
            Assignee Robin Müller [ coderhugo ] Owen Mehegan [ owenmehegan ]

            People

              owenmehegan Owen Mehegan
              anthonymastrean Anthony Mastrean
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: