Jenkins plugin git-parameter fetch working only once - jenkins

I'm using Git-parameter plugin into Jenkins to build specific tag/branches. It was correctly working but now (not sure it's following and update or something) it's failing in a strange way:
If I create a new job (or duplicate a failing one) add the git parameter to retrieve tag (or branch) and my build steps I can build right away. It shows me the full tag list and can build the one I select.
On the second run, when I click "build with parameter" again then no list provided for the tag and with the branch I have this error :
Command "git ls-remote -h ssh://jenkins#192.168.1.200/repo/git/xxx.git"
returned status code 128:
stdout:
stderr: /tmp/ssh3146539705442744984.sh: line 6: ssh: command not found
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Please look at the Log
So it looks like access issue to the git repo but it's working on first run and I still can build same project (so doing a git checkout too) without this git parameter so I assume my git configuration / credentials are ok.
If you have any idea where to look ?
ps: Jenkins is running on the same machine as the repository (a linux)
Jenkins 2.73.2
Git plugin 3.6.2
Git Parameter Plug-In 0.8.1
Thanks,
Nicolas.

Related

How to configure Git in Jenkins using windows platform

I'm trying to configure the git repository in Jenkins, I followed all steps on github documentation but I had the bellow error on my application .
I've configured the agent, then I put the ssh url on jenkins.
I've configured the ssh on github as well.
Failed to connect to repository : Command "git ls-remote -h -- git#github.com:user/maven-project.git HEAD" returned status code 128:
stdout:
stderr: git#github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists
The issue was solved that way
In windows, Jenkins will use the the SSH key of the user it is running as, which is located in the %USERPROFILE%.ssh folder ( on XP, that would be C:\Documents and Settings\USERNAME.ssh, and on 7 it would be C:\Users\USERNAME.ssh). Therefore, you need to force Jenkins to run as the user that has the SSH key configured. To do that, right click on My Computer, and hit "Manage". Click on "Services". Go to Jenkins, right click, and select "Properties". Under the "Log On" tab, choose the user Jenkins will run as, and put in the username and password (it requires one). Then restart the Jenkins service by right clicking on Jenkins (in the services window), and hit "Restart".
Jenkins does not support passphrases for SSH keys. Therefore, if you set one while running the initial Github configuration, rerun it and don't set one.
I'm going to say you don't have the credentials configured properly as you did not mention that.
A similar Stack Overflow response is here, for a slightly different worded error. Similar issue here.
The Jenkins site and others have good examples on setting up Jenkins with GitHub.

Jenkins: Git Failed to connect to repository, returned status code 128

I'm attempting to clone a remote GitHub enterprise repository and am running into the following error after adding my remote repo's URL to the Git Plugin in my Jenkins configuration:
Failed to connect to repository : Command "git.exe ls-remote -h https://<<server>>/M/AS.git HEAD" returned status code 128:
stdout:
stderr: fatal: unable to access 'https://<<server>>/M/AS.git/': Received HTTP code 502 from proxy after CONNECT
Firs of all You Need to setup github with jenkins in below section also
Go to Github --> click on profile dropdown --> settings --> devloper settings --> personal access token -->
generate new token --> select all scopes --> copy the token
Then go to Jenkins --> manage Jenkins --> github settings --> add user --> Select secret text--> paste the token
Then Test the git-hub connection by clicking test button If its Successful the Jenkins will ready to clone the GitHub repository
And also add Webhooks, Integrations & Services in GitHub
Make sure you have generated Git API Token in Git repository and added the same in the Jenkins Credentials.
If the is done, I don't think there will be any issue in connecting Git to Jenkins.
Also you can test if your Git server is able to ping your Jenkins server. (If you are running your own Git and Jenkins).
All the best.
Check your failed job environment variables.
If there is no environment variable named NO_PROXY, set one in the configuration of your JENKINS job:
NO_PROXY=.mycompany.com
Here, I assume your GitHub Enterprise has an URL like myserver.mycompany.com (replace (mycompany.com by your own)
That will avoid Jenkins trying to access the remote server through the proxy.
If you are running from a VM, make sure you install the package 'git-core'.
You must have git installed in the machine where jenkins is running
I had the same issue and for me it helped a restart for the machine where it was installed Jenkins.

Uploading projects from local computer to server by using Gitlab

I am completely new to Gitlab because previously I upload project to server using Filezilla. But now I have finished my Laravel projects in my local computer, and I would like to upload it to my could hosting. Currently my project is stored in c:\\xampp\htdocs\myproject.
Please tell me command line step-by-step to achieve this? I am using Putty on window. I can't understand it by reading existing tutorial.
I use DigitalOcean.com's server and yes I registered on gitlab.com to store/upload my project.
As a first approach, you can push directly to DigitalOcean, as describe in this tutorial:
clone your GitLab repo as a bare repo on your DigitalOcean instance (VPS: Virtual Private Server or Droplet)
cd
git clone --bare https://gitlab.com/<yourUsername>/<yourRepo.git>
add a post-receive hook similar to this auto-deploy article
That is:
cat > /home/rails/rails_project.git/hooks/post-receive
(Copy-paste the following lines)
#!/bin/sh
echo "-----------------------------------"
echo "Post receive hook: Updating website"
export GIT_WORK_TREE=/path/to/yourProject
export GIT_DIR=/home/yourUser/yourRepo.git
cd $GIT_WORK_TREE
git pull
git checkout master -f
(type Ctrl+D to exit)
Depending on your deployment path, you might have to execute the git commands as root, but it is best if you can keep your deployment as your username and not root.
But if you don't want to push to DigitalOcean, only to GitLab, you can use instead Git-Auto-Deploy.
Then you can push to GitLab, and that will trigger a deployment to your VPS.
When commits are pushed to your Git repository, the Git server will notify Git-Auto-Deploy by sending a HTTP POST request with a JSON body to a pre configured URL (your-host:8001).
The JSON body contains detailed information about the repository and what event that triggered the request.
Git-Auto-Deploy parses and validates the request, and if all goes well it issues a git pull.
Additionally, Git-Auto-Deploy can be configured to execute a shell command upon each successful git pull, which can be used to trigger custom build actions or test scripts.

After changing Maricurial url in hgrc, jenkins stuck on pull

My repository url was changed so I updated hgrc file with new url. I also updated new url in jenkins job.
Now when I am building the job, it hangs with the following output
-----------------Console Output-------------------
Started by user user123
Building in workspace D:\jenkins\jobs\api\workspace
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" showconfig paths.default
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" pull --rev branch
And it will never move forward. If i run the same command on cmd
"C:\Program Files\TortoiseHg\hg.exe" pull --rev branch
It works fine with following output
pulling from ssh://repos-url/repos-name
no changes found
But jenkins hangs on this command. Need some help to move forward.
Thank you
It sounds to me more a jenkins configuration question than a mercurial one :)
Are you talking about the identical clone of the repository? Does the jenkins user have read permissions on the repository it pulls from? Is it configured to pull via ssh, too and does it have the necessary ssh credentials? Or, if pulling via http, is hgweb running on the repo or another webserver to support hg?
Also, unless your project is called 'api', the URL looks strange to me: Jenkins (by default) has its clones in /jenkins-home-directory/jobs/projectname/workspace
As I mentioned in my question that I recently changed repository url. The issue was that new server's key was not cached in the registry where jenkins was hosted.
Resolution:
I logged in to the administrator account(same account used by jenkins) on my server through RDP and on the other side I started building the job in jenkins. When the console output came to this line
[workspace] $ "C:\Program Files\TortoiseHg\hg.exe" pull --rev branch
RDP window showed me an alert which was
Putty Security Alert
I pressed Yes and I saw jenkins console is now progressing and build was successful after that.

Configuring Jenkins with Cloud TFS (Supports GIT)

We are trying to configure Cloud TFS (Project Created with Git Support) & Jenkins (Ubuntu Machine).
When ever i try to enter the Repository URL it gives the following error.
Failed to connect to repository : Command "git ls-remote -h
https://xyz.visualstudio.com/DefaultCollection/_git/xyzrepo.git HEAD"
returned status code 128: stdout: stderr: fatal: Authentication
failed
I have generated keys using SSH route, but unfortunately i can't add the key # Cloud TFS Repo.
I have even tried this format https://USERNAME:PASSWORD#example.visualstudio.com/DefaultCollection/_git/Repo_Name but somehow was not successful.
PS: Bare minimum's are installed (GIT & Git plugin for Jenkins)
Any help/instructions is appreciated.
You probably need to enable Alternate Credentials in tfs.
Have a look at this howto

Resources