Jenkins git fetch returned status code 143 - linux

I'm facing the problem with Jenkins with fetching git repo on Linux. I attach the stack trace. I have SSH gitlab connection configured with a private key and a passphrase. The configuration is made in Credentials/System/Global credentials (unrestricted). The path to the private key is /home/jenkins/.jenkins/secrets/my_private_key.pub. Owner and a group: jenkins:jenkins, where jenkins is the user making the installation. Permissions: 600.
The private key has been checked with the passphrase using ssh from the command line. The git fetch command used by jenkins has also been checked with command line. Both works.
Repository URL format is like:
git#github.com:org-name/project.git (short notation for ssh protocol)
Environment:
* CentOS 7 64 bit
* openjdk version "1.8.0_131" 64 bit
* Jenkins ver. 2.67
* Git client plugin 2.4.6Git plugin 3.3.0 (3.3.1 is not helping too)
* GIT server Plugin 1.7
* GitLab Plugin 1.4.5 (1.4.6 is not helping too)
* SCM API Plugin 2.1.1
* Credentials Plugin 2.1.14
* Jenkins is run directly
* Jenkins was installed with yum installer
* Browser: Google Chrome 59
* GitLab Community Edition 9.3.5
* git version 1.8.3.1
Stack trace:
started by user Jenkins Admin
Building in workspace /home/jenkins/.jenkins/workspace/my_project
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url git#gitlab.repo:XYZ/docs/project.git #
timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
No valid HEAD. Skipping the resetting
> git clean -fdx # timeout=10
Fetching upstream changes from git#gitlab.repo:XYZ/docs/project.git
> git --version # timeout=10
using GIT_SSH to set credentials
> git fetch --no-tags --progress git#gitlab.repo:XYZ/docs/project.git
+refs/heads/*:refs/remotes/origin/* --depth=1
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git#gitlab.repo:XYZ/docs/project.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:809)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1076)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1107)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1212)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:415)
Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress git#gitlab.repo:XYZ/docs/project.git +refs/heads/*:refs/remotes/origin/* --depth=1" returned status code 143:
stdout:
stderr:
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:807)
... 11 more
ERROR: null
Finished: FAILURE

I found a solution. Running Jenkins as a service with systemctl resolved the problem, instead of running Jenkins with java -jar jenkins.war.
To give more details:
According to the documentation, Jenkins is started by
java -jar jenkins.war
And it was visible as running in the system when I checked it with:
ps aux | grep jenkins
However, on CentOS 7 the suggested way of running Jenkins is to run it as a daemon with systemctl command.
When I checked it with
sudo systemctl status jenkins.service
it was inactive.
So I started Jenkins with
sudo systemctl start jenkins.service
and it worked.

Related

keytar.node causing issues in Buildkite pipeline

I'm trying to create a CI/CD pipeline using buildkite where the build steps runs on a Virtual Machine (Ubuntu). However, an npm package called keytar which is a dependency of tedious library is causing issues in the pipeline.
When running one of the steps from using the buildkite-agent, it tries to clean up an existing repository. And during the command git clean -fxdq it fails to remove keytar.node file due to a Permission denied Error.
Here's a full log of the step:
> Running global environment hook
> Setting up plugins
> Preparing working directory
$ cd /var/lib/buildkite-agent/builds/build-server-1/someorg/some-repo
# Host "bitbucket.org" already in list of known hosts at "/var/lib/buildkite-agent/.ssh/known_hosts"
$ git remote set-url origin git#bitbucket.org:someorg/some-repo.git
$ git clean -fxdq
warning: failed to remove node_modules/keytar/build/Release/keytar.node: Permission denied
# Removing /var/lib/buildkite-agent/builds/build-server-1/someorg/some-repo
⚠️ Warning: Checkout failed! Error running `/usr/bin/git clean -fxdq`: exit status 1 (Attempt 1/3 Retrying in 2s)
# Host "bitbucket.org" already in list of known hosts at "/var/lib/buildkite-agent/.ssh/known_hosts"
$ git clone -v -- git#bitbucket.org:someorg/some-repo.git .
fatal: destination path '.' already exists and is not an empty directory.
# Removing /var/lib/buildkite-agent/builds/build-server-1/someorg/some-repo
⚠️ Warning: Checkout failed! Error running `/usr/bin/git clone -v -- git#bitbucket.org:someorg/some-repo.git .`: exit status 128 (Attempt 2/3 Retrying in 2s)
# Host "bitbucket.org" already in list of known hosts at "/var/lib/buildkite-agent/.ssh/known_hosts"
$ git clone -v -- git#bitbucket.org:someorg/some-repo.git .
fatal: destination path '.' already exists and is not an empty directory.
# Removing /var/lib/buildkite-agent/builds/build-server-1/someorg/some-repo
⚠️ Warning: Checkout failed! Error running `/usr/bin/git clone -v -- git#bitbucket.org:someorg/some-repo.git .`: exit status 128 (Attempt 3/3 Retrying in 2s)
# Skipping artifact upload, no checkout
🚨 Error: Error running `/usr/bin/git clone -v -- git#bitbucket.org:someorg/some-repo.git .`: exit status 128
Upon examining the permissions on the folder /some-repo using the ls -l command the permissions seem to be drwxr-xr-x and the owner is buildkite-agent. I'm stumped as how this file does not get deleted while all other files get deleted without any issue.

Not able to push code in Git from Travis CI cloud for node

I have already gone through the previous post related to my problem and I checked every steps described there. But till my problem does not get the solution.
1)I am trying to use Travis CI cloud (not any CLI client as I have to only work with cloud)with Github login for public repository for end to end integration for node project.
2) After test with Travis I use the Istanbul for code coverage and push back to Git the coverage report which will be further use by Sonar cloud.
3) The link for my project and travis.yml : https://github.com/arpitajava/ZynlaNew
4) I have created the personal token in Git Hub for Travis and set as GH_TOKN as env variable in Travis page as well as .travis.yml
5) Every steps in the .travis.yml file is executing fine expect the last step git push.
$ git commit -m "Travis build" Travis build
16 files changed, 1951 insertions(+), 1 deletion(-) It is showing that
it committed 17 files after git commit execution.
$ git push origin
master remote: Invalid username or password. fatal: Authentication
failed for 'https://github.com/arpitajava/ZynlaNew.git/' Done. Your
build exited with 0.

gitlab: git-http-push failed, return code 22

First of all my gitlab connection was broken by error 500 and 502. The server was unattended for a while. So i decided to reinstall:
#gitlab-ctl cleanse
#apt-get purge gitlab-ce
Installation:
https://about.gitlab.com/downloads/#ubuntu1404
After the gitlab was reachable and i could create a project and clone it.
After i tried to push a new file to my repo and got following message:
git add .
git commit -m "inital"
git push --set-upstream origin master
error: Cannot access URL http://<username>#gitlab.domain.de:<port>/group/project.git/, return code 22
fatal: git-http-push failed
error: failed to push some refs to 'http://<username>#gitlab.domain.de:<port>/group/project.git/'
The gitlab-check gives this information:
#gitlab-rake gitlab:check
everything was green, besides violett ones:
Uploads directory setup correctly? ... skipped (no tmp uploads folder yet)
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
Why i can clone but not push? I searched in several log-files, but got nothing useful.

gitlab 8.2.0 git not working

I installed gitlab 8.2.0 from source and followed the instructions on https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/install/installation.
When I run the checks with
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production
I get the following error:
Running /home/git/gitlab-shell/bin/check
Check GitLab API access: FAILED. code: 301
gitlab-shell self-check failed
Try fixing it:
Make sure GitLab is running;
Check the gitlab-shell configuration file:
sudo -u git -H editor /home/git/gitlab-shell/config.yml
Please fix the error above and rerun the checks.
Checking GitLab Shell ... Finished
Here is my config.yml file from /home/git/gitlab-shell:
user: git
gitlab_url: "http://www.example.com/gitlab"
http_settings:
#ca_path: /etc/ssl/certs
self_signed_cert: true
repos_path: "/home/git/repositories/"
auth_file: "/home/git/.ssh/authorized_keys"
redis:
bin: "/usr/bin/redis-cli"
namespace: resque:gitlab
socket: "/var/run/redis/redis.sock"
log_level: INFO
audit_usernames: false
Note that I am using the relative URL feature to run gitlab on www.example.com/gitlab. Also the server is behind a reverse proxy that terminates https to http if this should be of any relevance for this problem.
I also cant' push or pull any repositories. When I try to I get the following error:
git pull https://www.example.com/gitlab/test/testproject.git
Username for 'https://www.example.com': test
Password for 'https://test#www.example.com':
fatal: Couldn't find remote ref HEAD
Unexpected end of command stream
I also can't add any files to any project via the webUI. If I try to do so I get the following error
Commit was rejected by pre-receive hook
The log for this from production.log looks as follows:
Sarted POST "/gitlab/test/testprojekt/create/master" for 147.86.8.115 at 2015-11-26 15:24:43 +0100
Processing by Projects::BlobController#create as JSON
Parameters: {"new_branch"=>"master", "create_merge_request"=>"1", "commit_message"=>"test", "file"=># <ActionDispatch::Http::UploadedFile:0x007f776230faf8 #tempfile=# <Tempfile:/tmp/RackMultipart20151126-7584-308za1>, #original_filename="test2.txt", #content_type="text/plain", #headers="Content- Disposition: form-data; name=\"file\"; filename=\"test2.txt\"\r\nContent-Type: text/plain\r\n">, "namespace_id"=>"test", "project_id"=>"testprojekt", "id"=>"master"}
Completed 200 OK in 628ms (Views: 0.3ms | ActiveRecord: 3.3ms)
Started GET "/gitlab/test/testprojekt/new/master" for 147.86.8.115 at 2015-11-26 15:24:44 +0100
Processing by Projects::BlobController#new as HTML
Parameters: {"namespace_id"=>"test", "project_id"=>"testprojekt", "id"=>"master"}
Completed 200 OK in 85ms (Views: 49.6ms | ActiveRecord: 6.0ms)
I think you could try switching gitlab_url: "http://www.example.com/gitlab" to https -> gitlab_url: "https://www.example.com/gitlab"
Not sure if its a complete fix but its a recomendations.
EDIT:
config.yml line 4 should look like
ca_path: "/etc/ssl/certs"

Why does git clone hang when calling from a shell script which SSH's to a remote server?

I am writing a small app for those in the company who don't like command line and to help with productivity. The app runs a shell script which gets input from the user, uses it to SSH to a remote staging server and git clone the repo to that remote server. SSH keys are all good for the staging server and on Bitbucket. I can manually SSH into the server and git clone without any issue. I have also managed to get it to work going to a live server for initial setup. All other commands sent to the server are working.
The code used for this particular part is:
ssh $SUSER#$SHOST "git clone --depth 1 git#bitbucket.org:team/$SITEADDRESS.git --branch staging $CURRDIR"
I've also tried to run this manually from terminal with the following code:
ssh user#server "GIT_CURL_VERBOSE=1 GIT_TRACE=1 git clone -v --depth 1 git#bitbucket.org:team/repo.git --branch staging /path/to/folder"
This is the output I get:
trace: built-in: git 'clone' '-v' '--depth' '1' 'git#bitbucket.org:team/repo.git' '--branch' 'staging' '/path/to/folder'
Cloning into '/path/to/folder'...
trace: run_command: 'ssh' 'git#bitbucket.org' 'git-upload-pack '\''team/repo.git'\'''
trace: run_command: '--shallow-file' '/path/to/folder/.git/shallow.lock' 'index-pack' '--stdin' '--fix-thin' '--keep=fetch-pack 557 on ubuntu'
trace: exec: 'git' '--shallow-file' '/path/to/folder/.git/shallow.lock' 'index-pack' '--stdin' '--fix-thin' '--keep=fetch-pack 557 on ubuntu'
trace: built-in: git 'index-pack' '--stdin' '--fix-thin' '--keep=fetch-pack 557 on ubuntu'
At this point it just hangs without errors instead of moving on to remote: Counting objects: 4535, done. and cloning the repo.
I've been trying to get this working for quite a few hours now and have been unable to find any info on similar problems. Using Git v1.9.1

Resources