Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempting to use scm:tag in a Jenkins job for a Git repository that requires a username/password

Tags:

git

maven

jenkins

I am attempting to configure a Jenkins/Maven/Git release build job as described by Axel Fontaine (http://axelfontaine.com/blog/final-nail.html). I made the additions to my POM as he described, and configured my Jenkins job accordingly.

In the Source Code Management section I entered the Repository URL for our internally hosted instance of Stash (which requires a username and password - SSH keys are not an option): https://stash.mycompany.com/scm/st_proj/my_repo.git

I provided the username/password credentials.

As in the blog post I created a Maven pre-step that has the goals versions:set -DnewVersion=$BUILD_NUMBER.

And also as in the blog post I set the goals for the build to deploy scm:tag.

When the job executes I get the following error.

[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR]
(gnome-ssh-askpass:32706):  Gtk-WARNING **: cannot open display:
error: unable to read askpass response from '/usr/libexec/openssh/gnome-ssh-askpass'
fatal: could not read Username for 'https://stash.mycompany.com': No such device or address

I realize this is because the Git command is attempting to prompt me for a username and password, but since this is run as a Jenkins' job there is no display for it to send the prompt to.

Why am I being prompted for a username and password when I have them set earlier in the job configuration? I know they are correct because they were required to clone the repository.

like image 573
JoshOfAllTrades Avatar asked Mar 11 '14 18:03

JoshOfAllTrades


People also ask

How do I link my Git repository to Jenkins?

Step 1: go to your GitHub repository and click on 'Settings'. Step 2: Click on Webhooks and then click on 'Add webhook'. Step 3: In the 'Payload URL' field, paste your Jenkins environment URL. At the end of this URL add /github-webhook/.

How do I get Git credentials for Jenkins?

First, we need to add a Credential option there. For that purpose, we need to click on the Manage Jenkins option. Step 2: Then, a new tab will open. There we need to click on the Manage Plugin option to add the Credential option there.

What is SCM in Jenkins?

In Jenkins, SCM stands for "Source Code Management". This option instructs Jenkins to obtain your Pipeline from Source Control Management (SCM), which will be your locally cloned Git repository.


1 Answers

Another (and much better) solution:

In Jenkins instead of using the scm:tag goal, use the Git Publisher post-build action. Here you can set and push a tag to the repository and the plugin uses the credentials stored in Jenkins!

Screen capture of Git Publisher section

like image 198
JoshOfAllTrades Avatar answered Oct 02 '22 16:10

JoshOfAllTrades