Hello,
I’m trying to set up an IaC pipeline that deploys some resources using terraform. I am storing this pipeline in a top-level Jenkins file in our IaC repository. Our repository is stored on a self-hosted bitbucket server. I have created a multibranch pipeline with “Single repsitory & branch” as the branch source, and specified the correct repository URL and credentials there. However, when executing trying to create the pipeline from git (i.e. executing in Jenkins), the following error always occurs:
Started by user jgeens
Checking out git http://git.company.com/scm/projects/iac.git into /var/jenkins_home/workspace/test-multibranch_master@script/33bfda6085f3de58d76b3167bcee64b93e453f851a2e975119451d175e925a98 to read Jenkinsfile
The recommended git tool is: NONE
using credential stash-system-user
> git rev-parse --resolve-git-dir /var/jenkins_home/workspace/test-multibranch_master@script/33bfda6085f3de58d76b3167bcee64b93e453f851a2e975119451d175e925a98/.git # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url http://git.company.com/scm/projects/iac.git # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://git.company.com/scm/projects/iac.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1003)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1245)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1309)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:129)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:159)
at org.jenkinsci.plugins.workflow.multibranch.SCMBinder.create(SCMBinder.java:143)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
Caused by: hudson.plugins.git.GitException: Command "git config remote.origin.url http://git.company.com/scm/projects/iac.git" returned status code 128:
stdout:
stderr: fatal: not in a git directory
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2734)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2660)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2656)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1981)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1993)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.setRemoteUrl(CliGitAPIImpl.java:1601)
at hudson.plugins.git.GitAPI.setRemoteUrl(GitAPI.java:161)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:991)
... 8 more
ERROR: Error fetching remote repo 'origin'
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE
I have also tried a normal pipeline with pipeline definition “pipeline script from scm”, freestyle project, … but everything always returns this error.
I am on Jenkins 2.387.1 using Git plugin 5.0.0 and git client plugin 4.1.0.
Any help would be dearly appreciated!