这是我能够以这种方式实现的方法,但是,如果您知道更好的方法,我很乐意听到。
#!groovystage '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" }}


