1

I would like to read the revision number from Jenkins job when the job fails

Revision number:

enter image description here

Job script:

failure {
        echo 'JENKINS PIPELINE FAILED'

         notifyBitbucket 
            commitSha1: "${env.SVN_REVISION}", 
            considerUnstableAsSuccess: false, 
            credentialsId: 'UFCBitbucket', 
            disableInprogressNotification: true, 
            ignoreUnverifiedSSLPeer: true, 
            includeBuildNumberInKey: false, 
            prependParentProjectKey: false, 
            projectKey: '', 
            stashServerBaseUrl: 'https://bitbucket.url.local:8080'
    }

I have trouble with Jenkins environment variable - "${env.SVN_REVISION}". This variable returns null value.

I can not solve this problem. Please help to solve this problem Thanks in advance

1 Answer 1

1

I don't think the env-variable SVN_REVISION does even exist.

All available Git-plugin env-variables can be seen here (and the Jenkins' ones here).

I would suggest you use the following environment-variable to get the revision:

GIT_COMMIT - SHA1 of the commit used in this build

On the other hand you can get the revision also by executing the git command directly per sh / bash:

git rev-parse HEAD
Sign up to request clarification or add additional context in comments.

5 Comments

GIT_COMMIT also returns a null value
Can you please execute a 'git rev-parse HEAD' in the stage and check if there is printed something. The commit should usually get you the revision as well.
Thanks a lot for help.This solution helped me. I get revision number with this script revNum = sh(returnStdout: true, script: 'git rev-parse HEAD')
Ok, great. I will complete the answer :)
Feel free to give me some internet points by marking the answer as correct if you are satisfied with it :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.