Jenkins Service Account failing to pull from Git - jenkins

I am having some trouble that randomly started with Jenkins. All of our jobs have begin to fail and it looks like there is a credential issue with the service account we use to run our jobs. This randomly started. I have tried updating the version of Jenkins and the plugins, but there is no change. Here is the output we receive on any job that runs:
> git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git.exe config remote.origin.url https://site.visualstudio.com/_git/prodscripts # timeout=10
Fetching upstream changes from https://site.visualstudio.com/_git/prodscripts
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials site git repo
> git.exe fetch --tags --progress https://site.visualstudio.com/_git/prodscripts +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://site.visualstudio.com/_git/prodscripts
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:1810)
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 "git.exe fetch --tags --progress https://site.visualstudio.com/_git/prodscripts +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: Logon failed, use ctrl+c to cancel basic credential prompt.
fatal: Authentication failed for 'https://site.visualstudio.com/_git/prodscripts/'
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2016)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1735)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:420)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
I have also confirmed that the service account can login to our git repository with no issue and confirmed the security permissions on there for the account. I am completely clueless on how Jenkins operates and have inherited Jenkins from someone else, so I'm having a really tough time trying to figure out the problem. Any help would be greatly appreciated.
Edit: I would also like to add that when I try to look at the job configurations, I receive this:

Well, I don't know what happened, but it looks like it seemed to fix itself. After updating Jenkins, it's plugins and Git on the master, the next morning we update the service account creds and that didn't work. Then we tried to use the alternative credentials found in Azure DevOps. Right after adding them in, we went to a job to change the credentials, but we did not receive the error from the picture above with the service account creds selected. We ran the job with the original creds and it ran without issue.

Please make sure you are using the right credentials and if it has changed recently, don't forget to update it in Jenkins credential manager. I was facing a similar issue but when I updated the password - it resolved.

Related

Jenkins GitLab Community Edition Integration Error

I'm trying to integrate Jenkins (ver. 2.337) for our project on our gitlab.doman.com (GitLab Community Version 13.0.3), and it is deployed and running on Linux Centos on AWS EC2.
When I try to test using my GitLab Access Token, it gives me error stating Connection Timed Out.
When I try with Gitlab webhooks and SSH Key as credentials instead of Access Token, webhooks execute successfully, but the job on jenkins fails with the below errors.
I am quite new to Jenkins, and CI/CD. So, any guidance or help resolving this issue is greatly appreciated!
Jenkins Console Log:
Started by GitLab push by j****
Running as SYSTEM
Building in workspace /var/lib/jenkins/workspace/xx_xxxxx
The recommended git tool is: NONE
using credential 7c284997-927a-40d9-b1cf-02axxxxxxxxx
> /usr/bin/git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/xx_xxxxx/.git # timeout=10
Fetching changes from the remote Git repository
> /usr/bin/git config remote.origin.url git#gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git # timeout=10
Fetching upstream changes from git#gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git
> /usr/bin/git --version # timeout=10
> git --version # 'git version 1.8.3.1'
using GIT_SSH to set credentials GitLab_SSH_Key
> /usr/bin/git fetch --tags --progress git#gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git#gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:1001)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1242)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1302)
at hudson.scm.SCM.checkout(SCM.java:540)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1215)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:645)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:517)
at hudson.model.Run.execute(Run.java:1896)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44)
at hudson.model.ResourceController.execute(ResourceController.java:101)
at hudson.model.Executor.run(Executor.java:442)
Caused by: hudson.plugins.git.GitException: Command "/usr/bin/git fetch --tags --progress git#gitlab.sampledomain.co.kr:xx_xxxxxDetection/xx_xxxxx_detection.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: ssh: connect to host gitlab.sampledomain.co.kr port 22: Connection timed out
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 hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
... 11 more
ERROR: Error fetching remote repo 'origin'
Finished: FAILURE
A GitLab Access Token would work only for HTTPS URL (replacing your GitLab account password)
If you see Connection timed out both for HTTPS URL and SSH URL (git#gitlab.sampledomain.co.kr:... as in your question), it means gitlab.sampledomain.co.kr is not reachable from the Jenkins controller server which tries to contact your Git repository hosting server.
You need to make sure such a server can do a simple curl -v telnet://gitlab.sampledomain.co.kr:22 or curl -v telnet://gitlab.sampledomain.co.kr:443, before being able to run a service like Jenkins.

gitlab oauth2 authentication in jenkins

I have configured a jenkins test job just to clone a git repo and provided the "Repository URL" like below
https://oauth2:glpat-Vn4Vgvft7-2W4P1m4b4Z#gitlab.com/test/batch/test.git
but while running the job I am getting the console error output as below
Cloning the remote Git repository
Cloning repository https://oauth2:glpat-Vn4Vgvft7-2W4P1m4b4Z#gitlab.com/test/batch/test.git
> git init /jenkins/jobs/test/workspace # timeout=10
Fetching upstream changes from https://oauth2#gitlab.com/test/batch/test.git
> git --version # timeout=10
Setting http proxy: 10.203.195.26:8080
> git fetch --tags --progress https://oauth2#gitlab.com/test/batch/test.git
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
The question is, while it is cloning it is showing the URL as https://oauth2:pass#gitlab.com
but why the password is not coming while fetching?

Unable to clone Bit Bucket repository using Jenkins Job

I have created a Jenkins' job to clone, build and deploy the code on tomcat server. But every time I run the job it ends exactly after 10 mins with same error
10:57:59 ERROR: Error cloning remote repo 'origin'
10:57:59 [DeployPublisher][INFO] Build failed, project not deployed
10:57:59 Finished: FAILURE
I know the root cause which is timeout is set to 10 min by default while jenkins job triggers the clone command
10:47:57 > git.exe --version # timeout=10
10:47:58 > git.exe fetch --tags --force --progress -- repository-url +refs/heads/*:refs/remotes/origin/* # timeout=10
10:57:58 ERROR: Timeout after 10 minutes
10:57:59 ERROR: Error cloning remote repo 'origin'
What I couldn't figure out is how to increase this default timeout.
Followings are the list of Git plugins that I have been using
Plugins used
Any help would be appreciated. Thanks in Advance
I have looked into Jenkins documentation and found few Keywords and searching with them, ends up to the answer of my question.
Please refer to this for answer

How to checkout a Bitbucket Git-LFS repo in Jenkins?

I have a Git LFS setup on our Bitbucket server, and can clone it on my Mac since I'm the owner.
Now I'm trying to set this up so a Jenkins job can clone the repo, and so on the SCM section I have
Repository URL: git#server.company.com:user/path/repo.git
Credentials: uernamePwCreds
It can get to the repo fine, but when it tries to checkout a Git-LFS file, it gets the following access error. See the Permission denied (publickey) error on last line.
FATAL: Could not checkout 104e35fb26dc1d3ed1689523cccb6e97829c0feb
hudson.plugins.git.GitException: Command "git checkout -f 104e35fb26dc1d3ed1689523cccb6e97829c0feb" returned status code 128:
stdout:
stderr: Downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (144 KB)
Error downloading object: MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be41): Smudge error: Error downloading MarcomLite/lib/jets3t-0.6.1/cockpit-0.6.1.jar (716be4107b362e413dc1ae29dc88e9b79e680def2c725ecc2d73268c4ea66e75): batch request: Permission denied (publickey).: exit status 255
How do I setup the "Git-LFS-specific" level authentication?
I don't want to use a Jenkinsfile for now.
Try adding "Additional Behaviours" -> "Git LFS pull after checkout" in the Git section of the SCM configuration for your job.

Jenkins and git with custom port

I am trying to link a gitlab instance with a Jenkins instance. Due to being run in a DC/OS environment I cannot use the standard SSH port 22, so I am running gitlab on SSH port 16122 instead.
Gitlab displays SSH clone URLs in the format [git#git.company.de:16122]:user/test.git, which a normal git clone command understands. Also, Jenkins accepts this URI as SCM URI in the configuration screen (as evidenced by the error messages "invalid credentials" vanishing once I set the SSH key as credential that is configured as deploy-key in Gitlab.
The problem arises during actually building the job: jenkins for some unknown reason decides to double-urlencode the [ at the front of the URI and thus the build breaks:
Cloning repository %255bgit#git.company.de:16122]:user/test.git
> git init /var/jenkins_home/workspace/test # timeout=10
Fetching upstream changes from %25255bgit#git.company.de:16122]:user/test.git
> git --version # timeout=10
> git fetch --tags --progress %25255bgit#git.company.de:16122]:user/test.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress %25255bgit#git.company.de:16122]:user/test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
When I look at the raw XML of the job using xxd on the shell, there are no "invisible" ASCII chars or similar in front of the repo URL.
What causes this, and is there a way to fix this without having to manually rewrite every URL to ssh://git#git.company.de:16122/user/test.git?

Resources