see sample script below. somehow resembles how our pipeline looks like but not really obviously.
steps:
- step: &test-sonar
name: test and analyze on SonarCloud
script:
- {some command}
- {some command}
- {some command}
- {some command}
- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- pip install pytest
- pytest --cov=tests/ --cov-report xml:coverage-reports/coverage-report.xml --junitxml=test-reports/report.xml
- {some command}
- {some command}
- {some command}
- {some command}
- {some command}
- {some command}
- {some command}
- pipe: sonarsource/sonarcloud-scan:1.4.0
- step: &check-quality-gate-sonarcloud
name: Check the Quality Gate on SonarCloud
script:
- pipe: sonarsource/sonarcloud-quality-gate:0.1.6
this script is what we run whenever we merge into the master branch.
this would mostly also be the same set of scripts but the flags in the pytest command are slightly different.
and again for a scheduled pipeline, the scripts would be mostly the same with some slight changes the flags of the pytest command.
I wouldn't want to repeat the same script 3 times and I'm not sure how to make this a bit more reusable.
Only thing I can think of is using bitbucket variables to change how pytest is executed depending on the type of pipeline but I'm still wrapping my head around that as well.