Scenario:
You want shell script step output a variable even when script execution fails. An example below.
I am checking if DNS name exists. If it doesn't exist I want to fail the step so I can do failure execution strategy of retry mark as success.
At same time I want output variable available so I can use the output variable in subsequent steps.
However afaik there is no way to do an output variable if you want to mark step as failure.
set +e
echo "DNS name to test: $dnsname"
host $dnsname
dnsteststatus=$?
echo "DNS test returned status: $dnsteststatus"
if [ "$dnsteststatus" -eq 0 ];
then
echo "DNS name for $dnsname was found in DNS"
else
echo "DNS name for $dnsname was not found in DNS"
fi
Ex script.