Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update Jenkinsfile
chubing committed Oct 8, 2018
1 parent d5241b5 commit 91c611f
Showing 1 changed file with 41 additions and 14 deletions.
55 changes: 41 additions & 14 deletions Jenkinsfile
@@ -46,24 +46,51 @@ pipeline {
}
}
stage('Build') {
steps {
script {
try{
sh 'bin/rebuild.sh &> debug'
} catch(error) {
def error_details = readFile('./debug');
def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}"
sh "rm -f ./debug"
handleError(message)
}
}
}
stage('Test') {
steps {
script {
try {
sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0'
} catch (error) {
def error_details = readFile('./debug')
def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}"
sh "rm -f ./debug"
handleError(message)
}
}
}

stage('Push') {
steps {
script {
docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") {
def baseImg = docker.build("$maintainer/$imagename", "--no-cache .")
// scan the image with clair
sh 'docker run -p 5432:5432 -d --name clairdb arminc/clair-db:latest'
sh 'docker run -p 6060:6060 --link clairdb:postgres -d --name clair arminc/clair-local-scan:v2.0.5'
sh 'curl -L -o clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64'
sh 'chmod 755 clair-scanner'
sh "./clair-scanner --ip 172.17.0.1 -r test.out $maintainer/$imagename:latest"
// test the environment
sh 'docker kill clairdb'
sh 'docker rm clairdb'
sh 'docker kill clair'
sh 'docker rm clair'
sh 'cd test-compose && ./compose.sh'
// bring down after testing
sh 'cd test-compose && docker-compose down'
//// scan the image with clair
// sh 'docker run -p 5432:5432 -d --name clairdb arminc/clair-db:latest'
// sh 'docker run -p 6060:6060 --link clairdb:postgres -d --name clair arminc/clair-local-scan:v2.0.5'
// sh 'curl -L -o clair-scanner https://github.com/arminc/clair-scanner/releases/download/v8/clair-scanner_linux_amd64'
// sh 'chmod 755 clair-scanner'
// sh "./clair-scanner --ip 172.17.0.1 -r test.out $maintainer/$imagename:latest"
//// test the environment
// sh 'docker kill clairdb'
// sh 'docker rm clairdb'
// sh 'docker kill clair'
// sh 'docker rm clair'
// sh 'cd test-compose && ./compose.sh'
//// bring down after testing
//sh 'cd test-compose && docker-compose down'
baseImg.push("$tag")

}

0 comments on commit 91c611f

Please sign in to comment.