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

Provide easy access to current commit ID in Jenkinsfile

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Component/s: pipeline
    • Labels:
      None
    • Similar Issues:

      Description

      During old style jenkins jobs I can easily print current commit ID (e.g. GIT_COMMIT, SVN_REVISION) to the console.
      But when I want to use it in Jenkinsfile (multi-branch pipeline)I tried

      env.GIT_COMMIT
      

      It gives me null/empty output.
      Commit hash might be useful for informing some revision software about build that succeeded or failed (e.g. I want to use it to ping Atlassian Stash about my build).

      I think this is one of the basic SCM information that should be available (just like current branch name in env.BRANCH_NAME).

        Attachments

          Issue Links

            Activity

            krzyk krzyk created issue -
            krzyk krzyk made changes -
            Field Original Value New Value
            Description During old style jenkins jobs I can easily print current commit ID (e.g. GIT_COMMIT) to the console.
            But when I want to use it in Jenkinsfile I tried
            {code}
            env.GIT_COMMIT
            {code}

            It gives me null/empty output.
            Commit hash might be useful for informing some revision software about build that succeeded or failed (e.g. I want to use it to ping Atlassian Stash about my build).

            I think this is one of the basic SCM information that should be available (just like current branch name in {{env.BRANCH_NAME}}).
            During old style jenkins jobs I can easily print current commit ID (e.g. GIT_COMMIT, SVN_REVISION) to the console.
            But when I want to use it in Jenkinsfile (multi-branch pipeline)I tried
            {code}
            env.GIT_COMMIT
            {code}

            It gives me null/empty output.
            Commit hash might be useful for informing some revision software about build that succeeded or failed (e.g. I want to use it to ping Atlassian Stash about my build).

            I think this is one of the basic SCM information that should be available (just like current branch name in {{env.BRANCH_NAME}}).
            jglick Jesse Glick made changes -
            Link This issue duplicates JENKINS-26100 [ JENKINS-26100 ]
            jglick Jesse Glick made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Duplicate [ 3 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 170572 ] JNJira + In-Review [ 198892 ]
            abayer Andrew Bayer made changes -
            Component/s pipeline-general [ 21692 ]
            abayer Andrew Bayer made changes -
            Component/s workflow-plugin [ 18820 ]

              People

              • Assignee:
                jglick Jesse Glick
                Reporter:
                krzyk krzyk
              • Votes:
                1 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: