I am trying to integrate Jenkins with Gitlab.
1) Jenkins is in my private IP server.
2) I have generated the SSH key from the Gitbash and created a folder '.ssh' and pasted in the Jenkins directory.
3) give correct SSH path in Jenkins and also credentials.
4)have all the plugins.
Problem:
Jenkins is not able to authenticate Gitlab repository.
Error
Started by user jenkinadmin
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Hello World GitLab
> C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> C:\Program Files\Git\bin\git.exe config remote.origin.url git#gitlab.com:dhananjaymaurya/TAA_POC.git # timeout=10
Fetching upstream changes from git#gitlab.com:dhananjaymaurya/TAA_POC.git
> C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> C:\Program Files\Git\bin\git.exe fetch --tags --progress git#gitlab.com:dhananjaymaurya/TAA_POC.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git#gitlab.com:dhananjaymaurya/TAA_POC.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1051)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1082)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1278)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1720)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:404)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --tags --progress git#gitlab.com:dhananjaymaurya/TAA_POC.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Host key verification failed.
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:1752)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1495)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:64)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:315)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:795)
... 11 more
ERROR: null
Finished: FAILURE`
Related
I'm trying to set up a Multibranch pipeline in Jenkins with Bitbucket as the SCM. When I try to "Scan Multibranch Pipeline Now" this is the resulting console log.
> git --version # 'git version 2.36.0.windows.1'
using GIT_SSH to set credentials
> C:/Program Files/Git/cmd/git.exe ls-remote -h -- ssh://git(repo name here).git # timeout=10
Fetching upstream changes from origin
> C:/Program Files/Git/cmd/git.exe config --get remote.origin.url # timeout=10
using GIT_SSH to set credentials
> C:/Program Files/Git/cmd/git.exe fetch --tags --force --progress --prune -- origin +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: [Mon Jun 27 11:02:32 PDT 2022] Could not fetch branches from source 3387233e-6185-46fa-a65c-0d4072f28149
[Mon Jun 27 11:02:32 PDT 2022] Finished branch indexing. Indexing took 7.8 sec
FATAL: Failed to recompute children of MultiBranch Test
hudson.plugins.git.GitException: Command "C:/Program Files/Git/cmd/git.exe fetch --tags --force --progress --prune -- origin +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Repository not found
The requested repository does not exist, or you do not have permission to access it.
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:2671)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618)
at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:602)
at jenkins.plugins.git.AbstractGitSCMSource$8.run(AbstractGitSCMSource.java:588)
at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:394)
at jenkins.plugins.git.AbstractGitSCMSource.doRetrieve(AbstractGitSCMSource.java:350)
at jenkins.plugins.git.AbstractGitSCMSource.retrieve(AbstractGitSCMSource.java:588)
at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:641)
at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:278)
at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:166)
at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1032)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE
Originally, the multibranch was able to scan the repo and find the branches with Jenkinsfiles, but now that no longer works. In the first multibranch test which scanned and created pipelines for branches, when I try to build those branches it fails the build with the same error as above "repository not found".
I have a successful single Pipeline working for the same repository, specifically the develop branch. It is able to build on commits and pull the jenkinsfile from the repo, so it doesnt seem there is an access issue, but that is what the Multibranch pipeline is running into.
--------UPDATE-----------
Randomly, the scan worked. We are not sure what/if any changes prompted the sudden correct performance.
Manual git pull is able to copy latest master repository code but when I pull from Jenkins build job old master is getting pulled.
we can see old pull request in below logs but not the latest.
Please help me on this.
Thanks
01:48:26 > C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/refs/remotes/origin/master^{commit}" # timeout=10
01:48:26 > C:\Program Files\Git\cmd\git.exe rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
01:48:27 Checking out Revision b971a3367b2e015d83a34d0ba2cb92a3bf1e916a (refs/remotes/origin/master)
01:48:27 Enabling Git LFS pull
01:48:27 > C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10
01:48:27 > C:\Program Files\Git\cmd\git.exe checkout -f b971a3367b2e015d83a34d0ba2cb92a3bf1e916a # timeout=10
01:48:31 > C:\Program Files\Git\cmd\git.exe config --get remote.origin.url # timeout=10
01:48:31 using GIT_SSH to set credentials Manny Bitbucket Key
01:48:31 > C:\Program Files\Git\cmd\git.exe lfs pull origin # timeout=10
01:49:06 Commit message: "Merged in LicenseTestsScenario (pull request #41)"
I am trying to pull the changes from the Git and generate the build. But every time it gives the following error. I have tried all most all the solutions provided in stack overflow. But it didn't work. My disk space is also fine.
Please help me to resolve this issue.
[EnvInject] - Loading node environment variables.
Building in workspace /Users/Shared/Jenkins/Home/workspace/Proj_name
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
> /usr/bin/git config remote.origin.url
"URL of the git repo" # timeout=10
Fetching upstream changes from "URL of the git repo"
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --progress
"URL of the git repo"
+refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from
"URL of the git repo"
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at hudson.scm.SCM.checkout(SCM.java:504)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
at
hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
at hudson.model.Run.execute(Run.java:1794)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress "URL of the git repo"
+refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout:
stderr: error: git-credential-osxkeychain died of signal 15
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1721)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
... 11 more
ERROR: Error fetching remote repo 'origin'
Build did not succeed and the project is configured to only push after a successful build, so no pushing will occur.
In my case I had to clean all my setup (I got an external windows agent running with winSW)
remove the workspaces corresponding to your branch (+ the temp folder)
remove the logs file for winSW (if you are using winSW)
uninstall reinstall the winSW agent (relaunch the jenkins agent / java)
ensure that all steps as been executed as admin
after the cleaning it was working fine.
I have a problem when i set my own project.
I start to configure my Jenkins Job, and I done this:
create credential on Jenkins for gitlab user account
create access token on gitlab and use this token in Jenkins to enable it
and this is the job configuration
but when i start a build, after10 minutes i get this error
Started by user admin
Building in workspace /Users/Shared/Jenkins/Home/workspace/xxxxxxxxx
> /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url https://gitlab.xxxxxxxxx.git # timeout=10
Fetching upstream changes from https://xxxxxxxx.git
> /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials
> /usr/bin/git fetch --tags --progress https://xxxxxxxxxx.git +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://gitlab.xxxxxxx.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:825)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1092)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1123)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1212)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:566)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:491)
at hudson.model.Run.execute(Run.java:1737)
at hudson.matrix.MatrixBuild.run(MatrixBuild.java:314)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:421)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress https://xxxxxxxx.git +refs/heads/*:refs/remotes/origin/*" returned status code 143:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1970)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1689)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:380)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:823)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
So... how do i solve this?
I think to solve the question. Follow this guide to add and enable jenkins user http://www.cimgf.com/2015/05/26/setting-up-jenkins-ci-on-a-mac-2/
and, at the moment, works. Thanks all
Check this option "Timeout (in minutes) for clone and fetch operations" under "Advanced Clone Behaviors"
Default time-out is 10min.
I have a ruby on rails code in bitbucket private repository. And i have added my repository remote into jenkins as follows:
https://bitbucket.org/myuser_name/demo_app
followed by Credentials:
Kind: username and password
and i have given bitbucket username and password into it.
Before i am saving the project configuration i got no error under Repository URL. So i thought i configured source code management correct. But when i am building the project i am getting this error.
Building in workspace /var/lib/jenkins/workspace/demo_app
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://bitbucket.org/myuser_name/demo_app # timeout=10
Fetching upstream changes from https://bitbucket.org/myuser_name/demo_app
> git --version # timeout=10
using .gitcredentials to set credentials
> git config --local credential.username myuser_name # timeout=10
> git config --local credential.helper store --file=/tmp/git1159546302445779982.credentials # timeout=10
> git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*
> git config --local --remove-section credential # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://bitbucket.org/myuser_name/demo_app
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:810)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1066)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
at hudson.scm.SCM.checkout(SCM.java:485)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
at hudson.model.Run.execute(Run.java:1738)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:98)
at hudson.model.Executor.run(Executor.java:410)
Caused by: hudson.plugins.git.GitException: Command "git -c core.askpass=true fetch --tags --progress https://bitbucket.org/myuser_name/demo_app +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: error: cannot fork() for git credential-store --file=/tmp/git1159545779982.credentials get: Cannot allocate memory
error: cannot fork() for /bin/echo: Cannot allocate memory
fatal: could not read Password for 'https://myuser_name#bitbucket.org': No such device or address
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1719)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1463)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:63)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:314)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:808)
... 11 more
ERROR: null
Finished: FAILURE
So where am i going wrong?
It would be better to include your project with deployment keys instead of username/password.
To add deployment keys to your bitbucket project go to https://bitbucket.org/myuser_name/demo_app/admin/deploy-keys/ .
Add your keys to Jenkins. On the project configuration page 'Source Code Management' -> 'Credentials' -> 'Add'. Choose 'SSH Username and privat key'. Add your username 'git' and your privat key.
I do not know if today changed the way to do this, but some time ago I had to make a hook in Bitbucket to perform this task:
more info