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插件支持此模式。

相关文章

显卡天梯图2024最新版,显卡是电脑进行图形处理的重要设备,...
初始化电脑时出现问题怎么办,可以使用win系统的安装介质,连...
todesk远程开机怎么设置,两台电脑要在同一局域网内,然后需...
油猴谷歌插件怎么安装,可以通过谷歌应用商店进行安装,需要...
虚拟内存这个名词想必很多人都听说过,我们在使用电脑的时候...