I have setup my pipeline to include unit tests and integration tests.
Before deployment of my code, I run unit tests on the code in the pipeline, where if they fail the code will not be deployed. My pipeline looks a little like this:
.build_&_test_template: &build_test_template |
nvm install 18
nvm use 18
npm ci
npm run coverage
pipelines:
branches:
uat:
- step:
name: Deploy to UAT
deployment: test
script:
- *build_test_template
- *shared_deploy_template
So if that npm run coverage fails the conditions I have set on my jasmine test configuration, the code will not get to the shared_deploy_template.
I have since added an integration step that would run after the code has deployed (shared_deploy_template), looking a little like this:
.shared_postman_test_template: &shared_postman_test_template |
npm run postmanTests
pipelines:
branches:
uat:
- step:
...
script:
- *build_test_template
- *shared_deploy_template
- *shared_postman_test_template
Now if there are any failures resulting from shared_postman_test_template, I'd like to be able to roll back the deployment automatically.
Is there a way to automate the rollback of a deployment based on testing conditions?