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

后端 未结 5 1299
一整个雨季
一整个雨季 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:10

    I do not think the git plugin exports the last built revision as an environment variable, but the information is easily available using a simple shell command like:

    curl -sf "$BUILD_URL/api/xml?xpath=//lastBuiltRevision/SHA1/text()"
    

    BUILD_URL always points to the build's own page and the rest of the information seems to be available using the xml api.

提交回复
热议问题