Could Not Read Username for 'https //github.com'
Fixing could not read Username for 'https://github.com': No such device or address in Jenkins
; Date: Midweek Aug 12 2020
Tags: Git
You might have a successfully executing build chore in Jenkins, then all of a sudden need that build chore to push to a Github repository. For example, it might render a statically generated website to button to the gh-pages branch for display using Github Pages. But this inscrutable fault message comes up. In that location is a fairly simple gear up, specially if you're using an HTTPS URL to admission the Github repository.

In your normal user environs on your laptop you're probably using an SSH URL (git@github.com:{USER}/{REPO}.git
) to access your repository. But on Jenkins, you lot're probably using an HTTPS URL instead (https://github.com/{USER}/{REPO}.git
). This URL works cracking to clone the repository into a Jenkins workspace and perform a build. Just as soon as that chore needs to push to a Github repository that URL will not piece of work because the HTTPS URL does non have authentication.
On your normal user environment you might dimly remember how you fix remote Github access. That involves uploading an SSH public key into the Github back-end for every account you have. Yous might effort the same in the Jenkins environment, only that then relies on using the git@github.com:{USER}/{REPO}.git
URL which might non work correctly in Jenkins. (I did not examination that)
One choice is to initialize a Git Credentials Store using a process similar this:
$ git config credential.helper store $ git push button http://instance.com/repo.git Username: <type your username> Password: <type your countersign> [several days later] $ git push button http://example.com/repo.git [your credentials are used automatically]
This stores the user name and password into ~/.git-credentials
and is supposed to let you push to an HTTPS Git URL without inbound a countersign. In my instance this did non solve the issue.
What worked for me was creating a Github Personal Access Token and using an HTTPS URL that looks like this: https://{TOKEN}@github.com/{USER}/{REPO}.git
The personal access token is what it sounds like, an encoded string that identifies you to Github. It should be treated carefully, like a password, since that's what information technology is. In my case I'1000 the just person using my Jenkins installation, so I simply entered the URL as shown above into Jenkins. If this were a multi-person Jenkins installation there might be a unlike all-time exercise.
Github has instructions for setting upwards the personal admission token. Ane goes to the Settings surface area, clicks on Programmer Settings, and on the following page clicks on Personal Access Tokens. That page has some description, then a push labeled Generate New Token.
While generating the token you're given a long list of checkboxes. These determine the permissions levels associated with the token. In my case I just clicked on the repo choice to requite this token full permissions over repositories. The other permissions didn't seem appropriate. At the bottom is a button, Generate Token, that takes you to the admission tokens dashboard, at which point you can copy the encoded string to the dashboard.
In Jenkins, go to the dashboard for 1 of your projects and click on the Configure push button. In my projection, I have the Github URL in two locations -- I checked the Github project option, and entered the URL there -- and nether Source Code Management I selected Git and entered the URL there.
The URL to enter has this format: https://{TOKEN}@github.com/{USER}/{REPO}.git
Later on in the Jenkins task, I'm having it poll the source repository every 30 minutes.
Finally, in the build department, I added the command that causes a button to the Github repository. Prior to setting up this personal access token, that command failed, merely after calculation the token to the Github HTTPS URL, the command works.
Source: https://techsparx.com/software-development/git/jenkins-access.html
0 Response to "Could Not Read Username for 'https //github.com'"
Post a Comment