DenCowboy
DenCowboy

Reputation: 15076

Jenkins job: ignore error

I have a jenkins job which executes a shell script. The last step of the shell script is deleting the docker images which are on the server (except the images which are in use). This is my command:

set +x
docker rmi `docker images -aq`

output:

Error response from daemon: conflict: unable to delete 69a777edb6dc (must be forced) - image is referenced in one or more repositories
Error response from daemon: conflict: unable to delete 69a777edb6dc (must be forced) - image is referenced in one or more repositories
Error response from daemon: conflict: unable to delete d9d7acd2e160 (cannot be forced) - image is being used by running container 4e5ba6ffeaf0

How am I able to ignore the errors (because it's normal) + hiding the output of the command? (tried set +x but did not help)

Upvotes: 2

Views: 2549

Answers (2)

yorammi
yorammi

Reputation: 6458

It should be:

docker 2>/dev/null rmi docker images -aq | true

(only one pipe line)

Upvotes: 1

Alex O
Alex O

Reputation: 8164

Use

docker 2>/dev/null 1>&2 rmi `docker images -aq` || true

Upvotes: 3

Related Questions