1

I am running a Jenkins docker image and trying to do a git push to through GitHub.
I did git commit in the PostSteps(Execute Shell) and PostBuild Actions with Git Publisher.
Is there some specific authentication I need to give in Jenkins?
I am not able to figure it out.
Thanks a lot in advance.

ERROR:

Failed to push branch master to origin hudson.plugins.git.GitException: Command "git push HEAD:master -f" returned status code 128: stdout: stderr: remote: Invalid username or password. fatal: Authentication failed for '' at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)

Rao
  • 20,781
  • 11
  • 57
  • 77
Varbi
  • 89
  • 2
  • 8

1 Answers1

0

After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone, git fetch, git pull or git push:

$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://your_user_name@github.com': 
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'

Reason ?

From the GitHub Help documentation:

After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password.

For example, when you access a repository using Git on the command line using commands like git clone, git fetch, git pull or git push with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password.

Solution :

  1. Generate a Personal Access Token. (Detailed guide on Creating a personal access token for the command line.)
  2. Copy the Personal Access Token.
  3. Re-attempt the command you were trying and use Personal Access Token in the place of your password.

Related question: https://stackoverflow.com/a/21374369/101662

Community
  • 1
  • 1
LuFFy
  • 8,799
  • 10
  • 41
  • 59