In my Jenkins job, I am configuring git in the following way:
sh("git config user.email [email protected]")
sh("git config user.name my-user-name")
sh("git tag ${BUILD_NUMBER}")
sh("git push origin --tags")
However, on the last line, when I try to push to my repository, I get the following error about the repository:
fatal: could not read Username for 'http://my-git-repo.com:8000': No such device or address
What's wrong and how can I make it push to the repository?
Your user name is what immediately follows the https://github.com/ .
Git has an internal interface for storing and retrieving credentials from system-specific helpers, as well as prompting the user for usernames and passwords. The git-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for credentials in the same manner as Git.
The Git clone command will create a new local directory for the repository, copy all the contents of the specified repository, create the remote tracked branches, and checkout an initial branch locally. By default, Git clone will create a reference to the remote repository called origin .
You're looking for credential.username
. I don't know about the passphrase, but if you dislike http://username:[email protected]:8000
then put the credentials in your Jenkinsfile like so:
The second most common type of Credentials is "Username and Password" which can still be used in the
environment
directive, but results in slightly different variables being set.environment { SAUCE_ACCESS = credentials('sauce-lab-dev') }
This will actually set 3 environment variables:
SAUCE_ACCESS containing <username>:<password> SAUCE_ACCESS_USR containing the username SAUCE_ACCESS_PSW containing the password
credentials
is only available for Declarative Pipeline. For those using Scripted Pipeline, see the documentation for thewithCredentials
step.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With