Reputation: 141
I followed the microsoft page https://learn.microsoft.com/en-us/azure/devops/pipelines/process/set-variables-scripts?view=azure-devops&tabs=bash but it's not exactly working in my case. We are using templates, and folder structure looks like below:
The execution path is: validate-test-coverage.yml >> validate.yml >> test.yml >> test.sh >> publish-test.yml >> validate-coverage.yml >> coverage.sh
# file: bash/test.sh
# here we have deploy statement which returns status. 0 = success, 1 = failed
deploy_result_code=$?
if [ "$deploy_result_code" == "0" ]; then
echo "deployment success"
echo '##vso[task.setvariable variable=isDeploySuccess]true'
else echo "deployment failed"
fi
echo $deploy_result_code
if [ "$DEPLOY_ACTION" == "$ACTION_REPORT" ]; then exit 0
else exit $deploy_result_code; fi
# file: steps/validate-coverage.yml
steps:
- task: Bash@3
displayName: "Coverage results"
condition: eq(variables['isDeploySuccess'], 'true')
continueOnError: true
inputs:
filePath: '/bash/coverage.sh'
env:
NODE_NO_WARNINGS: 1
If deploy job fails, I get the below output but steps "Coverage results" also gets executed. How can I use variable 'isDeploySuccess' in condition to skip execution of "Coverage results" task?
deployment failed
1
Upvotes: -2
Views: 37