Jeevitha G
Jeevitha G

Reputation: 1234

GIT clone issue in Jenkins Permission Denied

I am trying to pull some documents from git using git clone as part of a jenkins process. Git clone works fine separately, but as a part of jenkins, I am facing permission denied issue

> echo "pw"| sudo git clone host@IP:git-repo 


> Cloning into 'git-repo'... 
Permission denied, please try again.
Permission denied, please try again.
Permission denied(publickey,password).

fatal: Could not read from remote repository.

Upvotes: 4

Views: 2406

Answers (3)

mahinlma
mahinlma

Reputation: 1258

Try this,

superuser ALL=(ALL) NOPASSWD:ALL - for single user 

refer link

This setting help us to bypass user prompt.

Upvotes: 0

Hitesh Chapanera
Hitesh Chapanera

Reputation: 46

Jenkins creates a system user to your system with name jenkins.

  1. SSH to your server.
  2. Switch user to jenkins.
  3. Try git clone.

Try adding jenkins user to sudores using this link and give permissions to this user, add SSH(git) key for git clone.

This may solve your issue. :)

Upvotes: 1

Jesse Glick
Jesse Glick

Reputation: 25491

Try using the SSH Agent plugin to make your private key accessible to regular build steps.

Upvotes: 1

Related Questions