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

I am attempting to configure a Jenkins/Maven/Git release build job as described by Axel Fontaine ( 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):

  • Is there any harm letting a git branch “grow old”?
  • Github token security using github.js
  • View a specific Git commit
  • Android Source, Git/Repo and error: '…/.repo/repo/.git/clone.bundle' does not look like a v2 bundle file
  • What do I need to read to understand how git works?
  • What is the best practice for dealing with passwords in github?
  • 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:
    (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 '': 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.

  • Where are Git's pack files stored?
  • Git selectively ignoring despite gitignore file
  • BitBucket and Merge Conflicts
  • Cannot see new files added to my git working directory
  • git mergetool reports “No files need merging”
  • Syncing my github forked repository with the upstream and keeping my changes
  • 3 Solutions collect form web for “Attempting to use scm:tag in a Jenkins job for a Git repository that requires a username/password”

    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

    After pounding on this for a while I’ve found a workaround – if not a solution. (Solutions are still welcome)

    1. Log into the Jenkins build slave (as the user that runs the build jobs)
    2. Set the credential cache git config --global credential.helper 'cache --timeout 600'

    Now when the credentials are used to clone the repository they are cached by Git for the subsequent push command.

    You need to configure your git credentials in maven too.

    First declare a server in maven settings.xml under <settings> <servers>


    then reference your server in your project pom.xml properties



    Git Baby is a git and github fan, let's start git clone.