mirror of https://github.com/docker/docs.git
Merge pull request #19004 from dvdksn/fix-jenkins-credentials-ex
scout: fix jenkins ci example
This commit is contained in:
commit
6358a48cd4
|
@ -5,22 +5,34 @@ title: Integrate Docker Scout with Jenkins
|
||||||
---
|
---
|
||||||
|
|
||||||
You can add the following stage and steps definition to a `Jenkinsfile` to run
|
You can add the following stage and steps definition to a `Jenkinsfile` to run
|
||||||
Docker Scout as part of a Jenkins pipeline. The pipeline needs two secrets
|
Docker Scout as part of a Jenkins pipeline. The pipeline needs a `DOCKER_HUB`
|
||||||
defined to authenticate with Docker Hub: `DOCKER_HUB_USER` and `DOCKER_HUB_PAT`
|
credential containing the username and password for authenticating to Docker
|
||||||
It also needs an environment variable defined for the image and tag.
|
Hub. It also needs an environment variable defined for the image and tag.
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
…
|
pipeline {
|
||||||
stage('Analyze image') {
|
agent {
|
||||||
steps {
|
// Agent details
|
||||||
// Install Docker Scout
|
}
|
||||||
sh 'curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- -b /usr/local/bin'
|
|
||||||
|
|
||||||
// Log into Docker Hub
|
|
||||||
sh 'echo $DOCKER_HUB_PAT | docker login -u $DOCKER_HUB_USER --password-stdin'
|
|
||||||
|
|
||||||
// Analyze and fail on critical or high vulnerabilities
|
environment {
|
||||||
sh 'docker-scout cves $IMAGE_TAG --exit-code --only-severity critical,high'
|
DOCKER_HUB = credentials('jenkins-docker-hub-credentials')
|
||||||
|
IMAGE_TAG = 'myorg/scout-demo-service:latest'
|
||||||
|
}
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Analyze image') {
|
||||||
|
steps {
|
||||||
|
// Install Docker Scout
|
||||||
|
sh 'curl -sSfL https://raw.githubusercontent.com/docker/scout-cli/main/install.sh | sh -s -- -b /usr/local/bin'
|
||||||
|
|
||||||
|
// Log into Docker Hub
|
||||||
|
sh 'echo $DOCKER_HUB_PSW | docker login -u $DOCKER_HUB_USR --password-stdin'
|
||||||
|
|
||||||
|
// Analyze and fail on critical or high vulnerabilities
|
||||||
|
sh 'docker-scout cves $IMAGE_TAG --exit-code --only-severity critical,high'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue