Jenkins2 - Getting error while trying to execute a Git command using 'Execute Shell'

128 Views Asked by At

I'm using Jenkins 2 and trying to execute below GIT command using 'Execute Shell' in Build section.

git config --global user.email $GITHUB_LOGIN git config --global user.name $GITHUB_LOGIN

git tag -a $BUILD_NUMBER -m "Version $BUILD_NUMBER" git push origin --tags

With this, I'm getting below error when i run the job

  • git push origin --tags fatal: could not read Username for 'https://github.com': Device not configured

In the build logs, And I've observed below statement and per my understanding, I believe Jenkins is using GIT_ASKPASS to pull the changes from GitHub.

using GIT_ASKPASS to set credentials GitHubCredentials

With that said, Can someone help me understand if I can use 'GIT_ASKPASS' to fix this issue? If yes, How can i use it in my situation?

1

There are 1 best solutions below

0
On

I got this resolved with the below code snippet

git config --global user.name <git_username>

git push https://<git_username>:<git_password>@<git_repo_url>  --tags