6

I'm stuck with this problem and I have no idea to solve it.

I have written a Shell script which will invoke my job using Jenkins CLI by passing my private key.Jenkins version is 2.121.1

java -jar jenkins-cli.jar -s http://localhost:8080 -i ~/.ssh/id_rsa build RTT/RTT-CI-Tools/RTT-CI-Tools-Distribute -s -p SLAVE_REGEX=testserver

Getting Error message as :

ERROR: anonymous is missing the Overall/Read permission

The same script works in another Jenkins (2.7.4). How to fix this issue.

user2439278
  • 1,222
  • 7
  • 41
  • 75
  • it's a permission issue you need give access to anonymous – rohit thomas Jun 26 '18 at 16:18
  • The script works in another jenkins where we didnt provide any access to anonymous. – user2439278 Jun 27 '18 at 08:13
  • you must give access if you want to run something especially in linux ....you can try this https://stackoverflow.com/questions/22717773/jenkins-github-authentication-error-user-is-missing-the-overall-read-permission – rohit thomas Jun 27 '18 at 10:57

3 Answers3

10

You can also use auth param but you should to type your password in console

java -jar jenkins-cli.jar -s http://localhost:8080/ -auth myLoggin:myPassword list-jobs
younes nedjar
  • 192
  • 2
  • 5
7

Please check for below points

1) USER exist on jenkins server as same on linux machine.

2) SSH Public key shared on Jenkins server is correct.(manage jenkins --> manage user --> click on ${USER} --> click on configure --> then check ssh public key is correct).

3) CMD i used(working) --> java -jar jenkins-cli.jar -ssh -user ${USER} -i ~/.ssh/id_rsa -s http://localhost:8080/jenkins/ build ${JOB_NAME}

please check if you are executing cmd from same user.

4) SSH port should be enable on Jenkins (go to manage Jenkins--> configure Global security --> SSH Server... set SSHD Port Fixed eg 38844)

K M
  • 196
  • 3
  • 9
Rohit Jindal
  • 667
  • 5
  • 13
  • Thanks, it worked for me. I also had to open access to Jenkins port 38844 from bastion host, because my Jenkins was in a private subnet. – hit3k Jan 22 '20 at 02:13
4

This issue cropped up for me, too, recently (using the cli to automate installing jenkins). I was able to work around it by setting the denyAnonymousReadAccess flag to false in jenkins' config.xml file, and restarting jenkins:

  <authorizationStrategy class="hudson.security.FullControlOnceLoggedInAuthorizationStrategy">  
    <denyAnonymousReadAccess>false</denyAnonymousReadAccess>  
  </authorizationStrategy>  
Justin Ludwig
  • 3,311
  • 2
  • 24
  • 17