Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add trivy to CI #3217

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ git push origin release/$RELEASE
| DOCKER_PUBLISH | false |
| RUN_TEST | true |
| OVERWRITE_DOCKER_LATEST_TAG | false |
| RUN_TRIVY_SCAN | true |

- [ ] Create a release branch for the harvest-metrics repo like so:
```bash
Expand Down Expand Up @@ -76,6 +77,7 @@ bin/harvest generate metrics --poller POLLERNAME
| DOCKER_PUBLISH | true |
| RUN_TEST | true |
| OVERWRITE_DOCKER_LATEST_TAG | true |
| RUN_TRIVY_SCAN | true |

- [ ] [Draft a new release](https://github.com/NetApp/harvest/releases). Use `v$RELEASE` for the tag and pick the release/$RELEASE branch.
- [ ] Type `$RELEASE` in the `Release title` text input
Expand Down
20 changes: 20 additions & 0 deletions jenkins/artifacts/jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pipeline {
string(name: 'DOCKER_PUBLISH', defaultValue: 'false', description: 'true to publish to dockerhub')
string(name: 'RUN_TEST', defaultValue: 'true', description: 'false to skip test')
string(name: 'OVERWRITE_DOCKER_LATEST_TAG', defaultValue: 'false', description: 'true to overwrite latest tag at dockerhub. Works only if DOCKER_PUBLISH is true')
string(name: 'RUN_TRIVY_SCAN', defaultValue: 'false', description: 'true to run Trivy image scan')
}

environment {
Expand Down Expand Up @@ -185,6 +186,25 @@ pipeline {
}
}

stage('Trivy Image Scan') {
when {
expression {
return params.RUN_TRIVY_SCAN == 'true';
}
}
steps {
script {
currentStage = 'Trivy Image Scan'
}
sh '''
curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sudo sh -s -- -b /usr/local/bin
export PATH=/usr/local/bin:$PATH
trivy image --db-repository public.ecr.aws/aquasecurity/trivy-db --exit-code 1 ${ghcrImage}:latest
trivy image --db-repository public.ecr.aws/aquasecurity/trivy-db --exit-code 1 ${ghcrImage}:latest-fips
'''
}
}

stage('Publish builds locally'){
steps {
script {
Expand Down