Right now, you can do:

      dimage = docker.image("whatever/whatever:99")
      

      This seems fine, until you try to spin up a container, where it throws an exception (that you can catch, which is great).

      dimage.withRun() { /* do nothing; just attempt to spin up container */ }
      

      The problem is that takes some time on a loaded server, because it spins up a container for no real reason.

      I would like a "validate" method. If that verb is too "heavy" and implies too much, "exists" would be fine, e.g.:

      dimage = docker.image("whatever/whatever:99")
      if (dimage.exists()) {
        ...
      }
      

      Workaround:

      image_id = sh (script: "docker images -q whatever/whatever:99", returnStdout: true).trim()
      if (image_id.isEmpty()) throw new Exception("Image not found")
      

          [JENKINS-45152] Should be able to check if image exists

          There are no comments yet on this issue.

            Unassigned Unassigned
            aarondmarasco_vsi Aaron D. Marasco
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: