[英]Jenkins multibranch pipeline use Variable in Project Repository
Our Jenkins instance holds a lot of pipelines that their source is in a private git server, so all the paths are ${SERVER_URL}/group/repo.git
.我们的 Jenkins 实例包含许多管道,它们的源位于私有 git 服务器中,因此所有路径都是
${SERVER_URL}/group/repo.git
。
Today, we are using a hard-coded path all over the Jenkins Pipeline Configurations and Jenkinsfile , but in order to replace the server, we want to generalize this URL, to be able to replace it in one place.今天,我们在Jenkins Pipeline Configurations和Jenkinsfile中使用硬编码路径,但是为了替换服务器,我们想推广这个 URL,以便能够在一个地方替换它。
We defined it as a Global Variable in Jenkins Configuration , and now we can use it in Jenkinsfiles by ${env.SERVER_URL}
, and in Pipeline Configuration by ${SERVER_URL}
:我们在Jenkins 配置中将其定义为全局变量,现在我们可以通过
${env.SERVER_URL}
在Jenkinsfiles中使用它,并通过${SERVER_URL}
在管道配置中使用它:
Now, I can't do that in the Multibranch Pipeline .现在,我不能在Multibranch Pipeline中这样做。 Using similar configuration:
使用类似的配置:
I'm getting the next error from the Scan Multibranch Pipeline Log :我从Scan Multibranch Pipeline Log收到下一个错误:
Started
[Wed Feb 24 16:54:59 IST 2021] Starting branch indexing...
> git --version # timeout=10
> git --version # 'git version 1.8.3.1'
using GIT_ASKPASS to set credentials tfsservices
> git ls-remote ${SERVER_URL}/MyGroup/MyProject # timeout=10
ERROR: [Wed Feb 24 16:54:59 IST 2021] Could not update folder level actions from source f3de808c-bb6b-49f3-b4f3-08a1b4e749f5
hudson.plugins.git.GitException: Command "git ls-remote ${SERVER_URL}/MyGroup/MyProject" returned status code 128:
stdout:
stderr: fatal: '${SERVER_URL}/MyGroup/MyProject' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1951)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1942)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteReferences(CliGitAPIImpl.java:3381)
at jenkins.plugins.git.AbstractGitSCMSource.retrieveActions(AbstractGitSCMSource.java:1148)
at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
[Wed Feb 24 16:54:59 IST 2021] Finished branch indexing. Indexing took 22 ms
FATAL: Failed to recompute children of build-name
hudson.plugins.git.GitException: Command "git ls-remote ${SERVER_URL}/MyGroup/MyProject" returned status code 128:
stdout:
stderr: fatal: '${SERVER_URL}/MyGroup/MyProject' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2450)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2051)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1951)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1942)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.getRemoteReferences(CliGitAPIImpl.java:3381)
at jenkins.plugins.git.AbstractGitSCMSource.retrieveActions(AbstractGitSCMSource.java:1148)
at jenkins.scm.api.SCMSource.fetchActions(SCMSource.java:848)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:598)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:165)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)
Finished: FAILURE
Yes it does not support.是的,它不支持。 You can use
Single repository & branch
.您可以使用
Single repository & branch
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.