0

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.

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.

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}:

enter image description here


The Question

Now, I can't do that in the Multibranch Pipeline. Using similar configuration:

enter image description here

I'm getting the next error from the 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
baruchiro
  • 5,088
  • 5
  • 44
  • 66
  • Can you please provide an example value for ${SERVER_URL}? – Itai Ganot Feb 24 '21 at 15:39
  • It is actually `http://tfs2018:8088/tfs/DefaultCollection`, Why does it matter? – baruchiro Feb 24 '21 at 16:05
  • 1
    Yea, it's not supported, many bugs regarding it have been opened over the years but they were all closed and the issue has never been solved. – Itai Ganot Feb 24 '21 at 17:28
  • 1
    try to use any job loader api, there you can easily achieve your scenario for both pipeline and multibranch pipeline . we are using [jenkins job builder](https://docs.openstack.org/infra/jenkins-job-builder/) extensively in our work and we loved it. This python library support a lot of scenario – Samit Kumar Patel Feb 24 '21 at 18:42

1 Answers1

1

Yes it does not support. You can use Single repository & branch.

Mustafa Güler
  • 884
  • 6
  • 11
  • But this way I can use only a specific branch, right? There is no "Behaviours: Discover branches" in the "Single repository & branch" – baruchiro Feb 28 '21 at 11:07