All I wanted to do was check if a docker container was running and if it was, stop it.
Simples.
Apparently not :(
Every time the Shell Execution Step with the following code ran, it marked the job as failed, if the docker container wasn't running.
docker ps|grep appserver || trueWhat isn't immediately obvious with Jenkins' Execute Shell build step is that it is run with -xe arguments.
if [ $? -eq 0 ]; then #appserver container is running - stop it
docker stop appserver
fi
The -e causes the step to fail for any part of the script that has a return status that isn't 0.
To override the the default behavior, one must add a shebang to the step's code as follows:
#!/bin/shVery annoying, but easily fixed.
docker ps|grep appserver || true
if [ $? -eq 0 ]; then #appserver container is running - stop it
docker stop appserver
fi