I have maven running a bash to build something with Docker.
<plugin>
...
<artifactId>maven-antrun-plugin</artifactId>
...
<exec executable="${basedir}/generate.sh" failonerror="true">
<arg value="${thrift.version}" />
...
The bash script runs something like:
for file in src/main/thrift/*.thrift; do
echo "Compiling ${file}"
docker run {...} thrift:${THRIFT_VERSION} thrift {...}
done
My problem is, when Docker can't find the version I'm requesting, it shows an error in console but it doesn't "fail": it just keeps building.
[exec] Compiling src/main/thrift/amsException.thrift
[exec] docker: Tag 0.9.0 not found in repository docker.io/library/thrift.
[exec] See 'docker run --help'.
[exec] Unable to find image 'thrift:0.9.0' locally
and consequently maven says
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
How can I make Docker throw and error when it can't find the version? My final goal is Maven failing to clean-install when this happens.
Cheers!
You can check docker run
exit code. If it's not 0, then abort your script.
for file in src/main/thrift/*.thrift; do
echo "Compiling ${file}"
docker run {...} thrift:${THRIFT_VERSION} thrift {...}
if [ $? != 0 ]; then
exit -1
fi
done