Add an Jenkins pipeline example #3688
Replies: 4 comments 1 reply
-
|
Hi there, sorry, I didn't see this before. I changed the discussion topic from "Show and Tell" to development. There are two ways that we could add this to the docs (also dependent on how much you want to be involved in updates, changes, etc.) -- you can do either of them or both of them, I would suggest both of them :)
Please let me know if I can help with anything :) |
Beta Was this translation helpful? Give feedback.
-
|
can we have something like , if the severity is high then jenkins job should fail |
Beta Was this translation helpful? Give feedback.
-
|
Yes, you can fail a job by adding these parameters: |
Beta Was this translation helpful? Give feedback.
-
|
I like the above suggestion. Works like a charm given one has also set a resource location in Jenkins so CSP works fine. Otherwise the report looks quite ugly .... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Trivy is really useful in CI/CD but there is no Jenkins integration in the document. I saw #257 requests a Jenkins plugin. Though I don't know how to write a Jenkins Plugin, I wrote an example Jenkins Pipeline that generates and publishes the report in HTML. Maybe I can add this somewhere in the document?
pipeline { agent any parameters { string(name: 'REGISTRY_NAME', defaultValue: '', description: 'Registry Name (Can be empty)') string(name: 'IMAGE_NAME', defaultValue: '', description: 'Image Name') string(name: 'IMAGE_TAG', defaultValue: '', description: 'Image Tag') } stages { stage('Scan Docker Image') { steps { script { def formatOption = "--format template --template \"@/usr/local/share/trivy/templates/html.tpl\"" def imageFullName = null if (params.REGISTRY_NAME == '') { imageFullName = "$IMAGE_NAME:$IMAGE_TAG" } else { imageFullName = "$REGISTRY_NAME/$IMAGE_NAME:$IMAGE_TAG" } sh """ trivy image $imageFullName $formatOption --timeout 10m --output report.html || true """ } publishHTML(target: [ allowMissing: true, alwaysLinkToLastBuild: false, keepAll: true, reportDir: ".", reportFiles: "report.html", reportName: "Trivy Report", ]) } } } }Screen shots of this example pipeline:


Beta Was this translation helpful? Give feedback.
All reactions