11

I need to remotely trigger a Jenkins build hosted on CloudBees. Right now, I'm attempting to use jenkins-cli to no avail. Right now I am authenticating using a SSH key pair.

When I do:

$ java -jar jenkins-cli.jar -s https://... list-jobs All

I can see all the jobs, including the one I want to build. But when I do:

$ java -jar jenkins-cli.jar -s https://... build job1
No such job 'job1'

I've read about a workaround that involves adding permissions to the anonymous role. Even if I add every single permission to it, I get the same error.

If it helps, I'm using Jenkins 1.532.1.3. Thanks.

Rodrigo López Dato
  • 1,144
  • 6
  • 13

3 Answers3

8

Today I ran into same problem and found the solution. The response 'no such job' comes when there is actually no such job or you don't have enough access to do requested operation. Even when you have the access for requested operation and you are sending credentials with --username and --password arguments it still not works. Only solution I found was to use ssh authentication. So register your computer's ssh key to your jenkins and everything works fine. To register ssh key go to http://[yourjenkinsserver]/user/[username]/configure

Pramod Jangam
  • 316
  • 3
  • 10
  • It worked for me with `-i [PRIVATE_KEY]` option. Looks like it is an open Jenkins issue: [JENKINS-12543](https://issues.jenkins-ci.org/browse/JENKINS-12543) – Ritesh Feb 24 '16 at 19:11
  • Can you provide me the steps? – karthick Mar 17 '16 at 20:26
  • +1 Thank you for this, helped me with version 1.625.18.5. [Issue 12543](https://issues.jenkins-ci.org/browse/JENKINS-12543) still unresolved. To use SSH for authenticated user: create key (*important: blank passphrase*); paste public key into user config; paste private key into new Jenkins credential for the user (again, blank passphrase). – groverboy Oct 17 '16 at 07:46
3

I ran into the same error but managed to make it work by providing read permission in 'job' for anonymous user.

anand
  • 618
  • 1
  • 9
  • 26
0

I encountered the same issue today on v1.621-1.1 while trying through a non-admin user which I named as 'vikas027'. In order to fix this I ticked all checkboxes under 'Job' column for user 'vikas027' and ticked 'Discover' and 'Read' (also under 'Job') for 'Anonymous' user. These settings are in http://<IP>:<port>/configureSecurity. Hope this helps someone.

vikas027
  • 5,282
  • 4
  • 39
  • 51