WASdev/ci.docker

Docker build didn't fail even though feature install step failed

Closed this issue · 2 comments

Reported in Slack

Feature install, using installUtility, failed with this error:

+ installUtility install --acceptLicense defaultServer
[0mChecking for missing features required by the server ...
The server requires the following additional features: ssl-1.0 localConnector-1.0 appSecurity-2.0 jsonp-1.0 jaxrs-2.0.  Installing features from the repository ...
Establishing a connection to the configured repositories ...
This process might take several minutes to complete.

[91mCWWKF1219E: The IBM WebSphere Liberty Repository cannot be reached. Verify that your computer has network access and firewalls are configured correctly, then try the action again. If the connection still fails, the repository server might be temporarily unavailable.
[0m[91m+ '[' 33 -ne 22 ']'
+ exit 0
[0mRemoving intermediate container 5128e928371d
 ---> 563275595fc2
Successfully built 563275595fc2

Even though above step failed, the docker build didn't fail. Seems like the exit code from installUtility operation is not returned by configure.sh

This is because the second return code ($?) is detecting the output from the if [...] and is returning true. For example:

#!/bin/bash

function main() {
	logic_should_cause_non_zero
	logic_does_cause_non_zero
}

function causeFail() {
	return 33
}

function logic_should_cause_non_zero() {
	causeFail || if [ $? -ne 22 ]; then echo "Exit code: $?"; fi
}

function logic_does_cause_non_zero() {
	causeFail || rc=$?; if [ $rc -ne 22 ]; then echo "Exit code: $rc"; fi
	causeFail || rc=$?; if [ $rc -ne 22 ]; then exit $rc; fi

}

main

will output:

./test.sh 
Exit code: 0
Exit code: 33

Resolved. Closing