詹金斯:“${env.SVN_REVISION}”变量 returns 空

Jenkins: "${env.SVN_REVISION}" variable returns null

我想在作业失败时从 Jenkins 作业中读取修订号

修订号:

作业脚本:

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'
    }

我在使用 Jenkins 环境变量时遇到问题 - “${env.SVN_REVISION}”。此变量 returns 空值。

我无法解决这个问题。请帮忙解决这个问题 提前致谢

我认为环境变量 SVN_REVISION 甚至不存在。

可以看到所有可用的Git-插件环境变量here (and the Jenkins' ones here)。

我建议您使用以下环境变量来获取修订版:

GIT_COMMIT - SHA1 of the commit used in this build

另一方面,您也可以通过直接执行 git 命令来获取修订版 sh / bash:

git rev-parse HEAD