How to integrate DSM with Azure DevOps using the DSM CLI
By default, Azure DevOps doesn't allow using variables at all stages of the pipeline. For other stages of this pipeline to access secrets, you must define them as environment variables.
- Access a project in your Azure DevOps account.
- Add the
dsm-cli
executable, the configuration file, and thesegura-mapping.json
file (if necessary) to the project repository. - Edit your
azure-pipelines.yml
file located in the project folder. - Include the code needed to run the DSM CLI at the desired point in your pipeline.
- Go to the pipeline variable settings.
- Register the variables needed to run the DSM CLI, following the guidelines provided in the user guide.
- Run the pipeline in Azure DevOps to complete the process.
Info
If you don't have the dsm-cli
and segura-mapping.json
files, ask the Segura® support team for them.
Example of an azure-pipelines.yaml
file using DSM CLI:
# This file is an example to demonstrate the usage of DSM CLI inside a Azure DevOps pipeline
# Make sure to upload the executable and the configuration files to your project
# For more information on its usage, please visit https://docs.Segura.io/
trigger:
- main
pool:
default
steps:
- script: |
dsm runb \
--app-name $APPLICATION \
--system $SYSTEM \
--environment $ENVIRONMENT \
--config .config.yml \
--tool-name azure-devops \
rm .runb.vars
displayName: 'DSM CLI Running Belt execution'
env:
APPLICATION: $(APPLICATION)
SYSTEM: $(SYSTEM)
ENVIRONMENT: $(ENVIRONMENT)
Info
Ensure you have selected the OAuth 2.0 authentication method in the Segura® DSM, as the CLI uses it to fetch information.
User the dsm-cli to inject secrets into pipelines in Azure DevOps
After configuring the DSM CLI in the project, follow the instructions below:
- Access Pipelines > Pipelines to run the pipeline.
- Select the pipeline you want and click Run Pipeline.
- In the next step, click Run.
- Then click on the job name to view the details and results of the execution.
The execution output will look like this:
Starting: Segura CLI Running Belt execution
========================================================================
Task : Command 1ine
Description : Run a comand line script using Bash on Linux and macOS and cmd.exe on Windows
Version: : 2.201.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devoos/oipelines/tasks/utility/comand-line
========================================================================
Generating script.
============== Starting Command Output ==============
usr/bin/bash --noprofile --norc /home/admin/azure-runner/work/temp/S0e477c1-6798-4F26-ba37-374b0c1bbOSS.sh
Using config file: .config.yml
Registering Application on DevSecOps
Trying to authenticate on Segura DevSecOps API
Authenticated successfully
Application register success
Posting variables in Segura...
Trying to authenticate on Segura DevSecOps API
Athenticated successfully
Posting variables successfully
Finding secrets from application
Trying to authenticate on Segura DevSecOps API
Athenticated successfully
Injecting secrets!
No secrets to be injected!
Deleting azure-devops variables...
No variables to be deleted!
Finishing: Segura CLI Running Belt execution
Do you still have questions? Reach out to the Segura Community.