Mercurial Plugin, Jenkins and Cloudbees - jenkins

I'm trying to run jenkins on my project hosted in bitbucket using mercurial. I have the following settings for mercurial:
repository url: http://bitbucket.org/myuser/myproject
credentials: username with password (I have my bitbucket username / password)
Revision Type: branch
Revision: default
When I run the build, I'm getting the following:
Started by user Me / Me
Building remotely on bec9ae7e (lxc-fedora17 m1.xlarge hi-speed xlarge) in workspace /scratch/jenkins/workspace/myproject
$ hg --config ******** clone --rev default --noupdate http://bitbucket.org/myuser/myproject /scratch/jenkins/workspace/myproject
abort: http authorization required
ERROR: Failed to clone http://bitbucket.org/myuser/myproject
ERROR: Failed to clone http://bitbucket.org/myuser/myproject
Finished: FAILURE
I'm not finding seeing where my appropriate credentials are being sent over. Plus, not sure what all of these config things are doing.

--config ******** is a masked version of the command-line option defining authentication. The form you quote seems to be for SSH private key authentication, which contradicts your claim that the specified credentials were a username/password pair (which would produce several --config options, some not masked). So I would double-check your credentials.

Related

Unable to connect to my bitbucket repo from jenkins

I have jenkins installed in EC2 instance. When i try to talk to bitbucket repo:
Failed to connect to repository : Error performing git command: git ls-remote -h
I'm seeing 1 problem on your git configuration, you don't have set any credentials there.
Try to set your user credentials (For bitbucket) on the Jenkins settings.
I tried applying the private key to jenkins credentials page and public key to bitbucket ssh settings page.
We tried a couple of jeknkins bitcucket plugins and and tried applying the following:
Add Credentials --> Username and password --> then the bitbucket username and password
Add Credentials --> Kind-->SSH Username and private key --> bitbucket username and passphrase as blank
Add Credentials-->Kind-->Bitbucket personal access token-->private key-->from the ssh -->username->>bitbucket -->passphrase as blank

Failed to connect to repository in Jenkins to GitLab

Error looks like:
Failed to connect to repository : Command "git ls-remote -h HEAD" returned status code 128:
stdout:
stderr: remote: HTTP Basic: Access denied
fatal: Authentication failed for
You are using the wrong user name and password:
1. create an API token against your username in your gitlab
2. Add the AccessToken and username in your Jenkins credentials. instead of using the username and password.
Just try out the connection:
log in to the Jenkins server and try to run the command 'git ls-remote -h url'
and provide user name and AccessToken which you have created in gitlab and configured in Jenkins.
It will provide an output if the username and API matches or else it will give an error as authentication failure...
And make sure your username has access to the repository
Go through LINK, which guides for how to create Global Credentials for Git API Token and for other users.
Create an Interpersonal User under Global Credential which you can then use in all Jenkins jobs.
Make sure that you add the SSH Private key (with Jenkins generate or of your choice's Credential Id), take a kind as 'SSH User with Private Key'
While creating Jenkins job in SCM > Git connection you can select credentials of Interpersonal User from Add dropdown.

Can't connect jenkins to gitlab

I have a setup of 2 VMs : VM1 with jenkins, VM2 with gitlab
On VM2 I have created a repo with user root with public access http://192.168.0.32/root/sparkjava_hello_world (acccess OK)
and generate the access token
On VM1:
- I installed the gitlab plugin in jenkins
- I copied the public key of user jenkins to authorized_key of user git in VM2 : from user jenkins shell, ssh git#VM2 is OK, no password asked
- I created the gitlab api credential and pasted the access token in it
- I configured the gitlab url in Manage Jenkins -> Configure System menu (it responds ok)
BUT when I setup the git source git#192.168.0.32:root/sparkjava_hello_world.git in my jenkins job, it doesnt work :
Failed to connect to repository : Command "/usr/bin/git ls-remote -h git#192.168.0.32:root/sparkjava_hello_world.git HEAD" returned status code 128:
stdout:
stderr: fatal: 'root/sparkjava_hello_world.git' does not appear to be a git repository
fatal: Could not read from remote repository.
I assume the ssh connection to VM2 is ok, since this is not a connection refused message.
I tried "ssh://git#192.168.0.32:root/sparkjava_hello_world.git" doesnt work either
What did i missed, or did wrong ??
thanks for help :)
Check that in VM2 you do have (as defined by default in a typical gitlab.yml) a /home/git/repositories/root/sparkjava_hello_world.git
Try an interactive ssh session on VM2 (from VM1), and do the ls-remote there:
ssh git#192.168.0.32
git ls-remote /home/git/repositories/root/sparkjava_hello_world.git
For Jenkins, what you need is to use your public key (~/.ssh/id_rsa.pub) as:
a deploy key on the GitLab side
a credential on the Jenkins side (see this tutorial)
Make sure to deploy that deploy key on your GitLab project (project settings/deploy keys), and then your Jenkins will be able to access your GitLab project (using that ssh key as credential).
Note: the normal use of a GitLab user key (like user xxx) in VM1 would be:
to define a user xxx in GitLab
to associate its public key in its user settings/ssh keys (that will modify ~git/.ssh/authorized_keys for you, adding a forced command line (this link is for gitolite, but it applies to gitlab too)
That means an ssh -T git#192.168.0.32 should not open an interactive session, but generate the message:
Welcome to GitLab, xxx

Failed to connect to repository : Command "git ls-remote -h

I have installed jenkins on my centos7 server and tried to build a maven build. Created a new maven build job and in SCM I was trying to pull the code from github but it showed me an error like...
Failed to connect to repository : Command "git ls-remote -h https://github.com/example.git HEAD" returned status code 128: stdout: stderr: remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/example.git/'
And also I setup an SSH public keys to my github. I don't know how to solve this. Anyone help me.Thanks in advance.
also I setup an SSH public keys to my github
That would have zero impact on an HTTPS URL: the SSH key is ignored.
Check if you havbe a git credential helper in place which might cache your credentials (GitHub username/password)
git config credential.helper
For instance, it could be 'cache'.
I would recommend (as in this answer) to set it to gnome-keyring:
git config --global credential.helper gnome-keyring
Then try again your git ls-remote, from command-line:
git ls-remote https://<yourUsername>#github.com/<yourUsername>/<yourRepo.git>
That should prompt for your GitHub username/password. Once entered, a second git ls-remote should not ask again for your credentials.
From there, an SCM process from your Jenkins, as long as said Jenkins runs with your account, should work.

Jenkins Failed to Connect to Repository

I am trying to connect Jenkins to a private BitBucket repository.
I have a set (both id_rsa and id_rsa.pub) of SSH keys generated at /var/lib/jenkins/.ssh. I've copied the id_rsa.pub key and pasted it in the deploy keys section of my BitBucket repository. Similarly, running the command git ls-remote -h git#bitbucket.org:user/project.git has a valid return and has been added to known_hosts.
What might be causing my Jenkins to not connect in the git Source Code Management section of Jenkins? The error returned is:
Failed to connect to repository : Command "git -c core.askpass=true ls-remote -h https://git#bitbucket.org/user/project.git HEAD" returned status code 128:
stdout:
stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
fatal: Authentication failed for 'https://git#bitbucket.org/user/project.git/'
I also tried ssh -Tv git#bitbucket.org as per this doc from Atlassian regarding troubleshooting SSH issues. The return states at that:
This deploy key has read access to the following repositories:
user/project: Jenkins -- jenkins#ip-xxx-xx-xx-xxx
For the Project Repository field that Jenkins' Git Plugin provides, it seems that one of their examples shown in their home page for that field (specifically, https://git#bitbucket.org/user/project.git) does not work. It might either be a case of plugin version, or how BitBucket might be configured differently than GitHub, of which their documentation uses for examples.
What did work for me however, was using the git address of the following format:
git#bitbucket.org:user/project.git

Resources