1

Team,

In Azure Devops yaml pipeline, where Im connecting to a server using ssh and running a curl command to look for an image presence in registry,

It works fine and gives back the result, but I want to fail the job if the curl command couldn't find the specific image.

Curl -s -X GET "https://registry/api/v2.0/Projects/test/repositories/repository%2Ftest-module/artifacts/1.0.0/tags?page=1&page_size=10&with_signature=false&with_immutable_status=false" -H "accept: application/json"

Image is available in the registry - The job succeeds with the artifactid, tag output

Image not available in the registry - Still the job succeeds with the output Errors code not found ..,

Basically, I need help to fail the job if no image in repository

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
Julie
  • 37
  • 6
  • Here's a bash sample on how to catch the HTTP status code from curl: https://stackoverflow.com/a/55434980/736079 then write an error to the log with the `logissue` command: https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#logissue-log-an-error-or-warning and mark it complete with the status error: https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#complete-finish-timeline – jessehouwing Mar 31 '23 at 11:49

0 Answers0