Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-11024

Some commands don't work when using _jenkins-cli.jar with -i switch, get-job and update-job for sure, not certain about others

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: Major Major
    • cli
    • None
    • CLI

      Add keys for authenticated login. Works fine with who-am-i, enable-job, disable-job, delete-job, create-job, but get-job and update-job fail claiming there is no job by that name. The very same command line with enable-job (as well as the others) works fine.

      Workaround is to see if enable-job fails (which it will if there is no job by that name, which was the point of using get-job), then delete-job and create-job instead of update-job if the job already exists. Note that this workaround causes the loss of job history upon deletion.

      Diagnostics:

      % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa get-job trunk-pacman.integration.vdev-regression
      No such job 'trunk-pacman.integration.vdev-regression'
      java -jar jenkins-cli.jar get-job args...
      Dumps the job definition XML to stdout
      JOB : Name of the job
      --username VAL : User name to authenticate yourself to Jenkins
      --password VAL : Password for authentication. Note that passing a
      password in arguments is insecure.
      --password-file VAL : File that contains the password

      % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa enable-job trunk-pacman.integration.vdev-regression
      % echo $?
      0

          [JENKINS-11024] Some commands don't work when using _jenkins-cli.jar with -i switch, get-job and update-job for sure, not certain about others

          Timothy Meazell created issue -
          Timothy Meazell made changes -
          Description Original: Add keys for authenticated login. Works fine with who-am-i, enable-job, disable-job, delete-job, create-job, but get-job and update-job fail claiming there is no job by that name. The very same command line with enable-job (as well as the others) works fine.

          Workaround is to see if enable-job fails (which it will if there is no job by that name, which was the point of using get-job), then delete-job and create-job instead of update-job if the job already exists.

          Diagnostics:

          % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa get-job trunk-pacman.integration.vdev-regression
          No such job 'trunk-pacman.integration.vdev-regression'
          java -jar jenkins-cli.jar get-job args...
          Dumps the job definition XML to stdout
           JOB : Name of the job
           --username VAL : User name to authenticate yourself to Jenkins
           --password VAL : Password for authentication. Note that passing a
                                 password in arguments is insecure.
           --password-file VAL : File that contains the password


          % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa enable-job trunk-pacman.integration.vdev-regression
          % echo $?
          0

          New: Add keys for authenticated login. Works fine with who-am-i, enable-job, disable-job, delete-job, create-job, but get-job and update-job fail claiming there is no job by that name. The very same command line with enable-job (as well as the others) works fine.

          Workaround is to see if enable-job fails (which it will if there is no job by that name, which was the point of using get-job), then delete-job and create-job instead of update-job if the job already exists. Note that this workaround causes the loss of job history upon deletion.

          Diagnostics:

          % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa get-job trunk-pacman.integration.vdev-regression
          No such job 'trunk-pacman.integration.vdev-regression'
          java -jar jenkins-cli.jar get-job args...
          Dumps the job definition XML to stdout
           JOB : Name of the job
           --username VAL : User name to authenticate yourself to Jenkins
           --password VAL : Password for authentication. Note that passing a
                                 password in arguments is insecure.
           --password-file VAL : File that contains the password


          % java -jar jenkins/_jenkins-cli.jar -s http://localhost:9090/ -i jenkins/id_rsa enable-job trunk-pacman.integration.vdev-regression
          % echo $?
          0

          I accenditaly reproduce this issue at work.

          When using -i for ssh credential, build and some other command doesn't work for job who are not readable by annonymous. (enable-job work)

          The workaround is to activate "security based project" and to activate read access to anonymous user.

          It must be a visibility issue. CLI see only anonymous job, not jobs seen by account used with -i parameter. On other way, the build start when anonymous have not build rights. So it's only visibility issue.

          Steve Eckerlein added a comment - I accenditaly reproduce this issue at work. When using -i for ssh credential, build and some other command doesn't work for job who are not readable by annonymous. (enable-job work) The workaround is to activate "security based project" and to activate read access to anonymous user. It must be a visibility issue. CLI see only anonymous job, not jobs seen by account used with -i parameter. On other way, the build start when anonymous have not build rights. So it's only visibility issue.

          S Daigle added a comment -

          Is this issue ever going to be resolved? In companies like mine where adding anonymous read access is not an option, and relying on many of the CLI commands, an issue like this limits the things we can do with Jenkins jobs outside the UI. If anyone has a workaround to this, that would be welcome.

          S Daigle added a comment - Is this issue ever going to be resolved? In companies like mine where adding anonymous read access is not an option, and relying on many of the CLI commands, an issue like this limits the things we can do with Jenkins jobs outside the UI. If anyone has a workaround to this, that would be welcome.

          gouzi added a comment -

          The 'build' command does not work either, as the job name cannot be retrieved:
          $ java -jar jenkins-cli.jar -s http://localhost:8090 -i ~/.ssh/id_rsa build Project1

          No such job 'Project1'
          java -jar jenkins-cli.jar build args...
          Starts a build, and optionally waits for a completion.
          (...)

          And Project1 does exist!

          gouzi added a comment - The 'build' command does not work either, as the job name cannot be retrieved: $ java -jar jenkins-cli.jar -s http://localhost:8090 -i ~/.ssh/id_rsa build Project1 – No such job 'Project1' java -jar jenkins-cli.jar build args... Starts a build, and optionally waits for a completion. (...) – And Project1 does exist!

          The build command work, but you have to give anonymous read access to your Project1. Then CLI command will see it.
          Must be a visibility issue...

          Steve Eckerlein added a comment - The build command work, but you have to give anonymous read access to your Project1. Then CLI command will see it. Must be a visibility issue...

          Kieran Shaw added a comment -

          Agreed that this is an important issue, I don't want to give anonymous read access just to be able to use the CLI.

          Kieran Shaw added a comment - Agreed that this is an important issue, I don't want to give anonymous read access just to be able to use the CLI.

          Same issue here.

          Barrett Strausser added a comment - Same issue here.

          Jan Gargulák added a comment -

          Same here. Anonymous access is not acceptable. Looking for workaround.

          Jan Gargulák added a comment - Same here. Anonymous access is not acceptable. Looking for workaround.

          Max Burdge added a comment -

          I would also like a solution or workaround for this issue.

          Max Burdge added a comment - I would also like a solution or workaround for this issue.

            Unassigned Unassigned
            tmeazell Timothy Meazell
            Votes:
            13 Vote for this issue
            Watchers:
            19 Start watching this issue

              Created:
              Updated:
              Resolved: