Skip to content

Commit

Permalink
Adding 1.0.1 libs to be used by docker-scan (#2700)
Browse files Browse the repository at this point in the history
* Adding 1.0.1 libs to be used by docker-scan

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

* Tweak comments

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>

Signed-off-by: Peter Zhu <zhujiaxi@amazon.com>
  • Loading branch information
peterzhuamazon authored Oct 6, 2022
1 parent 3d5bd99 commit 1778b73
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 119 deletions.
2 changes: 1 addition & 1 deletion jenkins/docker/docker-scan.jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lib = library(identifier: 'jenkins@1.0.0', retriever: modernSCM([
lib = library(identifier: 'jenkins@1.0.1', retriever: modernSCM([
$class: 'GitSCMSource',
remote: 'https://github.com/opensearch-project/opensearch-build-libraries.git',
]))
Expand Down
31 changes: 31 additions & 0 deletions tests/jenkins/TestDockerScanJob.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/


import jenkins.tests.BuildPipelineTest
import org.junit.Before
import org.junit.Test
import static com.lesfurets.jenkins.unit.global.lib.LibraryConfiguration.library
import static com.lesfurets.jenkins.unit.global.lib.GitSource.gitSource

class TestDockerScanJob extends BuildPipelineTest {

@Override
@Before
void setUp() {

super.setUp()

// Variables
binding.setVariable('IMAGE_FULL_NAME', 'alpine:3')

}

@Test
void DockerScan_test() {
super.testPipeline('jenkins/docker/docker-scan.jenkinsfile',
'tests/jenkins/jenkinsjob-regression-files/docker/docker-scan.jenkinsfile')
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
docker-scan.run()
docker-scan.modernSCM({$class=GitSCMSource, remote=https://github.com/opensearch-project/opensearch-build-libraries.git})
docker-scan.library({identifier=jenkins@1.0.1, retriever=null})
docker-scan.pipeline(groovy.lang.Closure)
docker-scan.timeout({time=30})
docker-scan.echo(Executing on agent [label:none])
docker-scan.stage(Parameters Check, groovy.lang.Closure)
docker-scan.script(groovy.lang.Closure)
docker-scan.stage(Scan Images, groovy.lang.Closure)
docker-scan.script(groovy.lang.Closure)
docker-scan.scanDockerImage({imageFullName=alpine:3, imageResultFile=scan_docker_image})
scanDockerImage.sh(
touch scan_docker_image.txt scan_docker_image.json
trivy image --clear-cache
docker rmi `docker images -f "dangling=true" -q` || echo
docker rmi alpine:3 || echo
trivy image --format table --output scan_docker_image.txt alpine:3
trivy image --format json --output scan_docker_image.json alpine:3
)
docker-scan.archiveArtifacts({artifacts=scan_docker_image.*})
docker-scan.script(groovy.lang.Closure)
docker-scan.postCleanup()
postCleanup.cleanWs({disableDeferredWipeout=true, deleteDirs=true})
docker-scan.sh(trivy image --clear-cache)

0 comments on commit 1778b73

Please sign in to comment.