|
1 | 1 | pipeline { |
2 | | - agent any |
3 | 2 |
|
4 | | - stages { |
5 | | - stage('Scan image') { |
6 | | - steps { |
7 | | - withCredentials([usernamePassword(credentialsId: 'sysdig-secure-api-credentials', passwordVariable: 'SECURE_API_TOKEN', usernameVariable: '')]) { |
| 3 | + parameters { |
| 4 | + string(name: 'DOCKER_REPOSITORY', defaultValue: 'sysdigcicd/cronagent', description: 'Name of the image to be built (e.g.: sysdiglabs/dummy-vuln-app)') |
| 5 | + string(name: 'GIT_REPOSITORY', defaultValue: 'https://github.com/sysdiglabs/secure-inline-scan-examples.git', description: 'Name of the repository with the Dockerfile to be built (e.g.: https://github.com/sysdiglabs/secure-inline-scan-examples.git)') |
| 6 | + string(name: 'SYSDIG_ENDPOINT', defaultValue: 'https://eu1.app.sysdig.com', description: 'The appropriate Sysdig vulnerability scanning endpoint depending on your region, see https://docs.sysdig.com/en/docs/administration/saas-regions-and-ip-ranges (e.g.: https://github.com/sysdiglabs/secure-inline-scan-examples.git)') |
| 7 | + } |
| 8 | + |
| 9 | + agent any |
| 10 | + stages { |
| 11 | + stage('Cloning Git') { |
| 12 | + steps { |
| 13 | + git branch: 'main', url: "${params.GIT_REPOSITORY}" |
| 14 | + } |
| 15 | + } |
| 16 | + stage('Build Image') { |
| 17 | + steps { |
| 18 | + sh "docker build -f ./jenkins/new-scan-engine/Dockerfile -t ${DOCKER_REPOSITORY} ./jenkins/new-scan-engine/" |
| 19 | + } |
| 20 | + } |
| 21 | + stage('Scan image') { |
| 22 | + steps { |
| 23 | + withCredentials([usernamePassword(credentialsId: 'sysdig-secure-api-token', passwordVariable: 'SECURE_API_TOKEN', usernameVariable: '')]) { |
| 24 | + sh ''' |
| 25 | + VERSION=$(curl -L -s https://download.sysdig.com/scanning/sysdig-cli-scanner/latest_version.txt) |
| 26 | + curl -LO "https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/${VERSION}/linux/amd64/sysdig-cli-scanner" |
| 27 | + chmod +x ./sysdig-cli-scanner |
| 28 | + ./sysdig-cli-scanner --apiurl ${SYSDIG_ENDPOINT} docker://${DOCKER_REPOSITORY} |
| 29 | + ''' |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + stage('Push Image') { |
| 34 | + |
| 35 | + steps { |
| 36 | + withCredentials([usernamePassword(credentialsId: 'registry-credentials', passwordVariable: 'password', usernameVariable: 'username')]){ |
8 | 37 | sh ''' |
9 | | - VERSION=$(curl -L -s https://download.sysdig.com/scanning/sysdig-cli-scanner/latest_version.txt) |
10 | | - curl -LO "https://download.sysdig.com/scanning/bin/sysdig-cli-scanner/${VERSION}/linux/amd64/sysdig-cli-scanner" |
11 | | - chmod +x ./sysdig-cli-scanner |
12 | | - ./sysdig-cli-scanner --apiurl https://secure.sysdig.com mongo-express:0.54.0 |
| 38 | + docker login -u ${username} -p ${password} |
| 39 | + docker push ${DOCKER_REPOSITORY} |
13 | 40 | ''' |
14 | | - } |
15 | | - } |
16 | | - } |
| 41 | + } } |
| 42 | + } |
17 | 43 | } |
18 | 44 | } |
0 commit comments