sor*_*rin 9 jenkins jenkins-workflow jenkins-pipeline jenkinsfile
我想标记当前的git变更集并从Jenkins文件中推送标记.如果标签已存在,则必须更换.
我想使用这个逻辑来标记与snapshot标记一起传递的构建,这将是一个移动标记.
我怎样才能做到这一点?
sor*_*rin 12
这是我能够以这种方式实现这一点的方式,但如果你知道更好的方式,我更愿意听到它.
#!groovy
stage 'build'
node {
repositoryCommiterEmail = 'ci@example.com'
repositoryCommiterUsername = 'examle.com'
checkout scm
sh "echo done"
if (env.BRANCH_NAME == 'master') {
stage 'tagging'
sh("git config user.email ${repositoryCommiterEmail}")
sh("git config user.name '${repositoryCommiterUsername}'")
sh "git remote set-url origin git@github.com:..."
// deletes current snapshot tag
sh "git tag -d snapshot || true"
// tags current changeset
sh "git tag -a snapshot -m \"passed CI\""
// deletes tag on remote in order not to fail pushing the new one
sh "git push origin :refs/tags/snapshot"
// pushes the tags
sh "git push --tags"
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13566 次 |
| 最近记录: |