My code is as follows:
stage('Infracost'){
agent {
docker {
image 'infracost/infracost:ci-latest'
args "--user=jenkins --entrypoint=''"
alwaysPull true
reuseNode true
}
}
environment {
INFRACOST_API_KEY = credentials('INFRACOST_API_KEY')
USAGE_FILE = '/tmp/infracost-usage.yml'
SYNC_USAGE_FILE = true
}
steps {
dir('./services/' + serviceType + '/terraform'){
sh script:'infracost breakdown --path .', label: "Infracost output"
sh script:'infracost diff --path plan.json', label: "Infracost diff"
}
}
}
What I would like to happen is if any part of this stage fails, then continue the pipeline. I have used this question for reference - Show a Jenkins pipeline stage as failed without failing the whole job
I have tried using catchError
in the steps of the stage and that answers my question partially. What I am seeing is that if the docker part fails for some reason, then the entire pipeline fails.
How do I allow for any part of this stage to fail and for the job to continue?