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

Pipeline fails on error within a sh command

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Blocker Blocker
    • pipeline
    • None
    • Jenkins ver. 2.176.3

      I wrote a Jenkins pipeline to copy remote images to the OpenShift repository with skopeo. Unfortunately I can't make the pipeline run due to a "unable to retrieve auth token: 401 unauthorized" error which quits the pipeline. However using the same command in the terminal works fine.

      So my guess is that Jenkins interpretes an error "{{Ping https://docker-registry.default.svc:5000/v2/ status 401" }}to fail and stop the whole command, while when I run the command in the terminal it shows the same message but continues and finish successfully.

      My pipeline step:

      sh """ 
         skopeo --tls-verify=false --debug inspect -- creds='${dest_user}:${dest_pw}' docker://${registry}/${namespace}/image:${build} 
      """

      The Jenkins pipeline output from the skopeo inspect call:

      time="2020-01-24T21:22:39Z" level=debug msg="Using registries.d directory /etc/containers/registries.d for sigstore configuration"
      time="2020-01-24T21:22:39Z" level=debug msg=" No signature storage configuration found for docker-registry.default.svc:5000/path/image:latest"
      time="2020-01-24T21:22:39Z" level=debug msg="GET https://docker-registry.default.svc:5000/v2/"
      time="2020-01-24T21:22:39Z" level=debug msg="Ping https://docker-registry.default.svc:5000/v2/ err "
      time="2020-01-24T21:22:39Z" level=debug msg="Ping https://docker-registry.default.svc:5000/v2/ status 401"
      time="2020-01-24T21:22:39Z" level=fatal msg="unable to retrieve auth token: 401 unauthorized"

      Then quits!

      While in the terminal I see the same ping with "status 401", but it continues:

      skopeo --tls-verify=false --debug inspect --creds=":" docker://docker-registry.default.svc:5000/path/image:latest
      DEBU[0000] Using registries.d directory /etc/containers/registries.d for sigstore configuration
      DEBU[0000] No signature storage configuration found for docker-registry.default.svc:5000/path/image:latest
      DEBU[0000] GET https://docker-registry.default.svc:5000/v2/
      DEBU[0000] Ping https://docker-registry.default.svc:5000/v2/ err
      DEBU[0000] Ping https://docker-registry.default.svc:5000/v2/ status 401
      DEBU[0000] GET https://docker-registry.default.svc:5000/v2/path/image/manifests/latest
      DEBU[0000] Downloading path/image-ui/blobs/sha256:ab3917277e589c0515309dde9c623746f32bb93c2a5afc9027a873c9bd0b0660c
      ......

      So something in Jenkins must force the command to stop. How can I avoid this and make Jenkins handle the command like it would be run from the Terminal.

       

            Unassigned Unassigned
            1codingmonkey Coding Monkey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: