Chr*_*ite 18 jenkins jenkins-pipeline
我似乎无法创建构建特定分支的Jenkins管道作业,其中该分支是构建参数.
这是一些配置截图:
(我试过
$BRANCH_NAME_PARAM
,${BRANCH_NAME_PARAM}
而且${env.BRANCH_NAME_PARAM}
,所有的变化同样的结果)
和构建日志:
hudson.plugins.git.GitException: Command "git fetch --tags --progress origin +refs/heads/${BRANCH_NAME_PARAM}:refs/remotes/origin/${BRANCH_NAME_PARAM} --prune" returned status code 128:
stdout:
stderr: fatal: Couldn't find remote ref refs/heads/${BRANCH_NAME_PARAM}
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1970)
Run Code Online (Sandbox Code Playgroud)
我显然做错了什么 - 关于什么的任何想法?
Chr*_*ite 34
https://issues.jenkins-ci.org/plugins/servlet/mobile#issue/JENKINS-28447
看起来它与轻量级结账有关.如果我在配置中取消选择此选项,我的参数变量将被解析
小智 10
结合 VonC 答案的示例更详细一点
1 . 配置名为 BRANCH 的扩展选择参数:
Run Code Online (Sandbox Code Playgroud)def command = "git ls-remote -h $gitURL" def proc = command.execute() proc.waitFor() if ( proc.exitValue() != 0 ) { println "Error, ${proc.err.text}" System.exit(-1) } def branches = proc.in.text.readLines().collect { it.replaceAll(/[a-z0-9]*\trefs\/heads\//, '') } return branches.join(",")
2 . 设置要构建的分支:$BRANCH
3 . 在 Jenkins 作业配置的“Pipeline”部分禁用“Lightweight checkout”复选框:
否则作业将失败并显示以下消息:“stderr:fatal: 找不到远程引用 refs/heads/${BRANCH”}”
4 . Build with parameter 执行 groovy 脚本,然后您将获得分支的下拉列表
归档时间: |
|
查看次数: |
9739 次 |
最近记录: |