How can I access the last built revision according to jenkins?

后端 未结 5 1293
一整个雨季
一整个雨季 2021-02-06 05:50

Near the top of my build console I see a \"Last Built Revision:\" w/ a revision #. How can I access this last built rev # in my build script? I\'m using Gradle, but I don\'t t

5条回答
  •  清歌不尽
    2021-02-06 06:20

    You can directly access the Jenkins BUILD_NUMBER as system environment variable.

    task getBuildNumber << {
        ext.env = System.getenv()
        ext.buildNumber = env.BUILD_NUMBER?.toInteger()
        println "Build Number: $buildNumber"
    }
    

提交回复
热议问题