Getting "Error: you must authenticate to access this jenkins" when trying to run "Java -jar jenkins-cls.jar -s http://localhost:8080 /help"

Viewed 12230

Getting below error

Error: you must authenticate to access this jenkins" when trying to run "Java -jar jenkins-cls.jar -s http://localhost:8080 /help

Steps performed as below,
1. Copied jenkins-cls.jar to the local drive.
2. Opened command prompt and navigate to path where jenkins-cls.jar is saved.
3. Type "Java -jar jenkins-cls.jar -s http://localhost:8080 /help" and press enter.

It should ask for pass-code but instead, it displayed message "Error: you must authenticate to access this jenkins".

Any help to resolve this query is highly appreciated.

4 Answers

Go to Manage Jenkins -> Configure Global Security ->

  1. Enable Security Checked
  2. Authorization -> Logged-in Users can do anything -> Checked allow anonymous read access

Restart Jenkins and try running

java -jar jenkins-cls.jar -s http://localhost:8080 help --username user --password pwd

or

java -jar jenkins-cls.jar -s http://localhost:8080 login -auth username:(password/token).

You have to pass your username and password while executing the command like as below:

java -jar jenkins-cls.jar -s http://localhost:8080 /help --username <userName> --password <password>

The file name is now changed from jenkins-cls.jar to jenkins-cli.jar.

Make sure the user is registered in jenkins front-end and Enable Security is checked for the user.

java -jar jenkins-cli.jar -s http://localhost:8080 -auth username:password

Go into Configure global security section, search for Allow anonymous read access, check it as true, apply and save.

Or you can just choose Anyone can do anything instead of Logged-in users can do anything

Test your command now, it should be work

Related