居然發現幾個解決方案,首先我從詹金斯這樣的(工作流管道改變了一些對象)modied腳本:
import hudson.FilePath
import org.eclipse.jgit.transport.URIish
node {
env.WORKSPACE = pwd()
stage 'Checkout'
checkout scm
def build = manager.build
def listener = manager.listener
def workspace = new FilePath(new File(env.WORKSPACE))
def environment = build.getEnvironment(listener)
final def project = build.getParent()
final def gitScm = project.getTypicalSCM()
final def gitClient = gitScm.createClient(listener, environment, build, workspace);
final def gitTagName = "TAG_NAME"
final def comment = "COMMENT"
final def remoteURI = new URIish("origin")
gitClient.tag(gitTagName, comment)
gitClient.push().tags(true).to(remoteURI).execute()
}
你需要運行腳本多次,然後允許執行代碼在詹金斯(管理詹金斯 - >在進程腳本批准)。
另一種解決方案,更簡單的(使用這個現在):
bat "\"${tool 'Git'}\" config user.email \"[email protected]\""
bat "\"${tool 'Git'}\" config user.name \"Virto Jenkins\""
bat "\"${tool 'Git'}\" commit -am \"Updated version number\""
bat "\"${tool 'Git'}\" push origin HEAD:master -f"
你必須有與詹金斯配置一個名爲「混帳」的Git工具。