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

Provide easy access to git branch name in multibranch workflow scripts

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      Popular maven plugins designed to give you access to the git branch name are ineffective when using the workflow Multibranch Plugin.

      For multbranch builds it's reasonable to expect use cases where the branch info is use to augment artifact names and manifest entries so people can easily distinguish branch built artifacts from one.

      Would be nice if the DSL just made this state available - but populating the env would be a nice start.

        Attachments

          Issue Links

            Activity

            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/jenkins/branch/BranchNameContributor.java
            src/main/resources/jenkins/branch/BranchNameContributor/buildEnv.jelly
            src/main/resources/jenkins/branch/BranchNameContributor/buildEnv.properties
            http://jenkins-ci.org/commit/branch-api-plugin/4f02e07e44726dc4277e29907c1f8e10ee06da22
            Log:
            Merge pull request #12 from jglick/branch-name-JENKINS-30252

            JENKINS-30252 Defining environment variable BRANCH_NAME

            Compare: https://github.com/jenkinsci/branch-api-plugin/compare/b8f6a22a92fa...4f02e07e4472

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/jenkins/branch/BranchNameContributor.java src/main/resources/jenkins/branch/BranchNameContributor/buildEnv.jelly src/main/resources/jenkins/branch/BranchNameContributor/buildEnv.properties http://jenkins-ci.org/commit/branch-api-plugin/4f02e07e44726dc4277e29907c1f8e10ee06da22 Log: Merge pull request #12 from jglick/branch-name- JENKINS-30252 JENKINS-30252 Defining environment variable BRANCH_NAME Compare: https://github.com/jenkinsci/branch-api-plugin/compare/b8f6a22a92fa...4f02e07e4472
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java
            multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java
            http://jenkins-ci.org/commit/workflow-plugin/7e91ca4f506e596f2abab4c1d45ca076fd30e2c4
            Log:
            JENKINS-30252 Verifying that ${env.BRANCH_NAME} works.
            Also clarifying that BranchJobProperty.branch is nonnull, always.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java http://jenkins-ci.org/commit/workflow-plugin/7e91ca4f506e596f2abab4c1d45ca076fd30e2c4 Log: JENKINS-30252 Verifying that ${env.BRANCH_NAME} works. Also clarifying that BranchJobProperty.branch is nonnull, always.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java
            multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java
            http://jenkins-ci.org/commit/workflow-plugin/8803a3e713d041cda74031829fa8b13a496642ae
            Log:
            Merge pull request #236 from jglick/branch-name-JENKINS-30252

            JENKINS-30252 Verifying that ${env.BRANCH_NAME} works

            Compare: https://github.com/jenkinsci/workflow-plugin/compare/85553288ab80...8803a3e713d0

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java http://jenkins-ci.org/commit/workflow-plugin/8803a3e713d041cda74031829fa8b13a496642ae Log: Merge pull request #236 from jglick/branch-name- JENKINS-30252 JENKINS-30252 Verifying that ${env.BRANCH_NAME} works Compare: https://github.com/jenkinsci/workflow-plugin/compare/85553288ab80...8803a3e713d0
            Hide
            marcuss Marcus Sjölin added a comment - - edited

            This feature seem to have gone into 1.11, however I cannot get this to work in 1.13

            node {
                    // Mark the code checkout 'stage'....
                    stage 'Checkout'
                    // Get some code from a GitHub repository
                    checkout([$class: 'GitSCM', branches: [[name: 'develop'], [name: 'feature/*']], doGenerateSubmoduleConfigurations: false, submoduleCfg: [], userRemoteConfigs: [[credentialsId: '...', url: 'ssh://git@giturl']]])
                    echo "${BRANCH_NAME} ${env.BRANCH_NAME}"
            }
            
            Show
            marcuss Marcus Sjölin added a comment - - edited This feature seem to have gone into 1.11, however I cannot get this to work in 1.13 node { // Mark the code checkout 'stage' .... stage 'Checkout' // Get some code from a GitHub repository checkout([$class: 'GitSCM' , branches: [[name: 'develop' ], [name: 'feature/*' ]], doGenerateSubmoduleConfigurations: false , submoduleCfg: [], userRemoteConfigs: [[credentialsId: '...' , url: 'ssh: //git@giturl' ]]]) echo "${BRANCH_NAME} ${env.BRANCH_NAME}" }
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java
            multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java
            multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java
            http://jenkins-ci.org/commit/workflow-multibranch-plugin/05869c106e5dc5aadfab507673b7b888d7ae5584
            Log:
            JENKINS-30252 Verifying that ${env.BRANCH_NAME} works.
            Also clarifying that BranchJobProperty.branch is nonnull, always.

            Originally-Committed-As: 7e91ca4f506e596f2abab4c1d45ca076fd30e2c4

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/BranchJobProperty.java multibranch/src/main/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowBranchProjectFactory.java multibranch/src/test/java/org/jenkinsci/plugins/workflow/multibranch/WorkflowMultiBranchProjectTest.java http://jenkins-ci.org/commit/workflow-multibranch-plugin/05869c106e5dc5aadfab507673b7b888d7ae5584 Log: JENKINS-30252 Verifying that ${env.BRANCH_NAME} works. Also clarifying that BranchJobProperty.branch is nonnull, always. Originally-Committed-As: 7e91ca4f506e596f2abab4c1d45ca076fd30e2c4

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                rpomeroy Ronald Pomeroy
              • Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: