Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins Git plugin - 401

I've tried all sort of different things and I can't get jenkins to play nice with git.

I have setup my ssh keys and verified that I can ssh to the git hub and I get the message. I also, have tried w/o the .git extention. I've tried with user name in the url, user name and password in the url, and no username/passsord at all. Fails to matter waht.

I've also tried it with an admin user and a plain push/pull user.

The git repository I'm trying to hit is through an "organization" but I'm on a team that has access.

Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone https://github.com/xxx/xx
hudson.plugins.git.GitException: Could not clone https://github.com/xxx/xx
    at hudson.plugins.git.GitAPI.clone(GitAPI.java:245)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1073)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1014)
    at hudson.FilePath.act(FilePath.java:788)
    at hudson.FilePath.act(FilePath.java:770)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1014)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:579)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:468)
    at hudson.model.Run.run(Run.java:1408)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:478)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Caused by: hudson.plugins.git.GitException: Error performing command: git clone --progress -o origin https://github.com/xxxx/xx /var/lib/jenkins/jobs/test/workspace
Command "git clone --progress -o origin https://github.com/xxxx/xx /var/lib/jenkins/jobs/test/workspace" returned status code 128: Initialized empty Git repository in /var/lib/jenkins/jobs/test/workspace/.git/
error: The requested URL returned error: 401 while accessing https://github.com/xxxx/xx/info/refs
like image 596
Douglas Ferguson Avatar asked Mar 04 '12 09:03

Douglas Ferguson


People also ask

How does the Git client plugin work with Jenkins?

The Git Client plugins uses GIT_ASKPASS and creates a temporary script to execute when git prompts for credentials. This approach requires that the user running Jenkins or the Agent has the sufficient permissions (read/write/execute) on the temp folder. This has always been true for SSH Authentication.

What are the guidelines for repository URLs in Jenkins?

Repository URL's should follow the git URL guidelines. Git steps to access a secured repository should provide a Jenkins credential with the credentialsId argument rather than embedding credentials in the URL. Credentials embedded in a repository URL may be visible in console logs or in other log files.

How to use JGit with Git client plugin?

GitClient git = Git.with (listener, environment) .in (repository) .using (gitExe) .getClient (); Using "jgit" will force use of JGit implementation. The Git Client plugins uses GIT_ASKPASS and creates a temporary script to execute when git prompts for credentials.

How do I check for changes in a Jenkins repository?

Checkout from the Jenkins platform labeler repository using https protocol, no credentials, the master branch, and no polling for changes. If poll is false, then the remote repository will not be polled for changes. If poll is true or is not set, then the remote repository will be polled for changes.


2 Answers

Try using the r/w address for cloning private repos using ssh keys:

[email protected]:xxx/xx.git

like image 150
iltempo Avatar answered Oct 16 '22 15:10

iltempo


If you pass the credentials on the URL, make sure they're URL encoded. Also make sure you're using Basic authentication.

like image 33
Scott Coates Avatar answered Oct 16 '22 15:10

Scott Coates