Jenkinsfile get current tag

后端 未结 8 1926
南笙
南笙 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:56

    I believe the git command that does what you want is git tag --points-at=HEAD this will list all tags pointing to the current commit or HEAD as it usually called in git. Since HEAD is also the default argument you can also do just git tag --points-at.

    The pipeline step for executing and returning the git tags one for each line, then becomes:

    sh(returnStdout: true, script: "git tag --points-at")

提交回复
热议问题