[英]Jenkins pipeline - is it possible to checkout both a branch or a tag
In a jenkins pipeline, using the git checkout scm syntax, is it possible to checkout both - either a branch or a tag from a remote repo in same code.在 jenkins 管道中,使用 git checkout scm 语法,是否可以同时检查两者 - 同一代码中来自远程仓库的分支或标签。
For ex -对于前 -
checkout([$class: 'GitSCM',
branches: [[name: '$branchortagname']],
userRemoteConfigs: [[
url: '$url',
refspec: '+refs/tags/*:refs/remotes/origin/tags/*
]]
])
The above works for a tag checkout.以上适用于标签结账。 Without the refspec, it works for a branch checkout.没有 refspec,它适用于分支结帐。 Whats the correct syntax to use for both in same bit of code - tag and branch在同一段代码中使用的正确语法是什么 - 标记和分支
So I didn't find how to set it using the full checkout setting.所以我没有找到如何使用完整的结帐设置来设置它。 However, if you use just the plain checkout scm without any additional settings in a multi-branch pipeline, it will checkout a tag if you are on a tag, and a branch if you are on a branch:但是,如果您在多分支管道中仅使用普通的 checkout scm 而没有任何其他设置,则如果您在标签上,它将签出一个标签,如果您在一个分支上,它将签出一个分支:
script {
checkout scm
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.