Configuring Jenkins with Cloud TFS (Supports GIT) - tfs

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

Related

Why am I unable to configure ssh keys to read a Gerrit repo from Jenkins?

I am in the process of trying to migrate Gerrit and Jenkins to a new datacenter. I have successfully installed the applications on their new hardware, but am having difficulty getting Jenkins to read from a Gerrit repository on the same server.
As the Jenkins user already existed on the server, I updated its ssh keys using one I generated from my account on my laptop (pablo#mena-xps), using the following command:
cat ~/.ssh/id_rsa.pub | ssh -p 29418 pmena#gerrit_host gerrit set-account --add-ssh-key - jenkins
I confirmed that I am able to use this key to interrogate gerrit from my laptop:
pablo#mena-xps=> ssh -p 29418 pmena#gerrit_host gerrit version
gerrit version 2.10
On the Jenkins server, I added the Private key under "Credentials" and then Configured the specific job to use that key to access a specific gerrit repo. That returns the following error in the GUI:
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h ssh://gerrit_host:29418/my_repo HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
How do I go about troubleshooting this issue? Thank you in advance.
To make a long story short, this issue is resolved. The Jenkins account on Gerrit was removed and recreated, after which I was able to successfully push the ssh key pair.

Jenkins projects Failed to connect to repository

Using the steps outlined here I lifted and shifted our Jenkins instance from one windows machine to another windows machine.
Jenkins on the new server launches successfully.
However, the integration with GitHub on all the projects is failing with the following error.
Failed to connect to repository : Command "git.exe ls-remote -h
git#github.com:some_repo_name.git HEAD" returned status code 128:
stdout: stderr: some_user#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.
What have I done wrong?

Jenkins on Linux Server Behind VPN Not Connecting to GitHub Webhook

I'm setting up continuous integration of a GitHub repository to automatically be pulled down by Jenkins onto a Linux server that is behind my company VPN that I do not control.
I have setup an Private SSH Key as both Jenkins Credentials and GitHub Deploy Key. I keep getting authenticating errors when Jenkins tries to connect to the SSH Repository URL. Is the VPN causing GitHub to not be able to POST to the server? Or am I missing something else?
ERROR MESSAGE:
Failed to connect to repository : Command "git ls-remote -h git#github.com:MyOrganization/MyRepository.git HEAD" returned status code 128:
stdout:
stderr: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

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.

Jenkins plugin git-parameter fetch working only once

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.

Resources