What
This capability allows application teams to inject custom steps into the CI pipeline. You can use preBuildSteps and/or postBuildSteps, which determines if your custom steps run before or after the docker build.
Why
Application teams might need to run additional tasks before and/or after the build has completed. For example, pushing coverage results to an external tool, performing blackduck scans, etc..
How
-
Create a steps template file (for example, 'blackduck-scan.yml'):
steps:
- task: secretBatchRetrievalConnector@1
displayName: "Conjur Integration"
inputs:
ConjurService: "conjur-dnt"
secretsyml: "./sdl_secrets.yml"
- bash: |
echo "Blackduck User: $BLACKDUCK_API_USER"
echo "Blackduck Token: $BLACKDUCK_API_TOKEN"
echo "Something User: $something_user"
echo "Something Pass: $something_pass"
displayName: Debug variables
env:
BLACKDUCK_API_USER: $(BLACKDUCK_API_USER)
BLACKDUCK_API_TOKEN: $(BLACKDUCK_API_TOKEN)
something_user: $(something_user)
something_pass: $(something_pass) -
Optionally, create a variable group (for example, 'sdl_test') with some variables (for example,
something_userandsomething_pass). Then, include that variable group in yourazure-pipelines.yml:variables:
- group: sdl_test -
Optionally, create a CyberArk/Conjur secrets file (for example, sdl_secrets.yml).
BLACKDUCK_API_USER: !var prodvault/CloudOne_LOB/S-D-C-RNCHR-CNJR-jon/aiq_blackduck_token/username
BLACKDUCK_API_TOKEN: !var prodvault/CloudOne_LOB/S-D-C-RNCHR-CNJR-jon/aiq_blackduck_token/password -
Update your
azure-pipelines.ymlto inject the steps using one of the options below.- Option 1: This might be useful if you want multiple pipelines to execute the same steps. You can use variables to make it dynamic to support multiple pipelines.
Option 1 - Locally store steps within pipeline repo
This might be useful if the steps are custom/unique to this particular pipeline and will not be used for any other pipeline.
-
Store the steps template that you created earlier (for example, 'blackduck-scan.yml') within the same repo as your
azure-pipelines.ymlfile (for example, ./steps/blackduck-scan.yml). -
Add the following to your
extends.parameterssection (example only):extends:
parameters:
build:
postBuildSteps:
- template: steps/blackduck-scan.yml@self
Option 2 - Centrally stored steps in another repo
This might be useful if you want multiple pipelines to execute the same steps. You can use variables to make it dynamic to support multiple pipelines.
-
Store the steps template that you created earlier (for example, 'blackduck-scan.yml') in another repo (for example, 'blackduck').
-
Add the following to your
resources.repositoriessection (example only):resources:
repositories:
- { repository: blackduck, type: git, name: blackduck-template-test, ref: main } -
Add the following to your
extends.parameterssection (example only):extends:
parameters:
build:
postBuildSteps:
- template: steps/blackduck-scan.yml@blackduck