Jenkins Pipeline 动态指定 gitUrl 和 gitBranch

0. 本次只针对jenkins 流水线和多分支流水线的job类型讲解动态指定git的问题

在这里插入图片描述

1. 错误的配置如下图

在这里插入图片描述
执行报错

15:29:43  Started by user admin
15:29:43  Rebuilds build #18
15:29:43  hudson.plugins.git.GitException: Command "git fetch --tags --progress --prune -- origin +refs/heads/master:refs/remotes/origin/master" returned status code 128:
15:29:43  stdout: 
15:29:43  stderr: fatal: '${PIPELINE_GIT_URL}' does not appear to be a git repository
15:29:43  fatal: Could not read from remote repository.
15:29:43  
15:29:43  Please make sure you have the correct access rights
15:29:43  and the repository exists.
15:29:43  
15:29:43  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
15:29:43  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
15:29:43  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
15:29:43  	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:573)
15:29:43  	at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:365)
15:29:43  	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
15:29:43  	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
15:29:43  	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:115)
15:29:43  	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:69)
15:29:43  	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:309)
15:29:43  	at hudson.model.ResourceController.execute(ResourceController.java:100)
15:29:43  	at hudson.model.Executor.run(Executor.java:433)
15:29:43  Finished: FAILURE

2. 正确的配置如下图

在这里插入图片描述

3.轻量级检查的名词解释

英文描述

If selected, try to obtain the Pipeline script contents directly from
the SCM without performing a full checkout. The advantage of this mode
is its efficiency; however, you will not get any changelogs or polling
based on the SCM. (If you use checkout scm during the build, this will
populate the changelog and initialize polling.) Also build parameters
will not be substituted into SCM configuration in this mode. Only
selected SCM plugins support this mode.

中文描述

如果选中,请尝试直接从SCM获取管道脚本内容,而不执行完全签出。这种模式的优点是效率高;但是,您不会得到任何基于SCM的变更日志或轮询。(如果在构建期间使用checkout
scm,这将填充变更日志并初始化轮询。)在这种模式下,构建参数也不会被替换到SCM配置中。只有选定的SCM插件支持此模式。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

特特专属

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值