Integrating with Azure DevOps pipeline
How to integrate Kubescape to Azure DevOps pipelines
Use Azure DevOps pipelines to scan your YAML files for misconfigurations with Kubescape. Scan results are included as part of your pipelines.
Add scanning YAML files to your workflow
Scan your repository using either the YAML pipeline or the classic pipeline.
YAML pipeline
-
In the root of your repository, create a file named
azure-pipelines.yml
. -
Add the following to the file to scan the Kubernetes objects in your YAML files.
trigger: - master pool: vmImage: 'ubuntu-18.04' container: jmferrer/azure-devops-agent:latest steps: - script: | mkdir $HOME/.local/bin export PATH=$PATH:$HOME/.local/bin curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash kubescape scan . displayName: 'Run Kubescape'
-
Run the pipeline, and view the results in the pipeline logs.
-
Add a Publish Test Results task to allow the pipeline to parse your results.
- task: PublishTestResults@2 inputs: testResultsFormat: 'JUnit' testResultsFiles: 'results.xml'
-
Run the pipeline again to enable Azure DevOps to parse the results.
Classic pipeline
-
Create a
kubescape-scan.sh
file in your code repository, and then add the following: (pointing to the YAML files you are about to scan in the command line instead of*.yaml
)#!/bin/bash mkdir $HOME/.local/bin export PATH=$PATH:$HOME/.local/bin curl -s https://raw.githubusercontent.com/kubescape/kubescape/master/install.sh | /bin/bash kubescape scan --format junit --output results.xml .
-
Add a bash script task and point it to
Kubescape-scan.sh
. -
Point to the
kubescape-scan.sh
file. -
Add a Publish Test Results task after the Kubescape scan task.
-
Point to
results.xml
. -
Save and run the pipeline.
After the pipelines run, Azure DevOPs parses the scan results.
Updated 12 months ago