Jenkinsfile get current tag

后端 未结 8 1917
南笙
南笙 2021-02-05 10:15

Is there a way to get the current tag ( or null if there is none ) for a job in a Jenkinsfile? The background is that I only want to build some artifacts ( android APKs ) when t

8条回答
  •  再見小時候
    2021-02-05 10:32

    All the other answers yield an output in any case even if HEAD is not tagged. The question was however to return the current tag and "null" if there is nothing like that.

    git tag --contains yields the tag name name if and only if HEAD is tagged.

    For Jenkins Pipelines it should look like this:

    sh(returnStdout: true, script: "git tag --contains").trim()

提交回复
热议问题