manage artifacts
Some checks failed
dockers/alpine/pipeline/head There was a failure building this commit
Some checks failed
dockers/alpine/pipeline/head There was a failure building this commit
This commit is contained in:
parent
a2ff103a2d
commit
0d293e4fcf
1 changed files with 29 additions and 1 deletions
30
Jenkinsfile
vendored
30
Jenkinsfile
vendored
|
@ -13,7 +13,7 @@ pipeline {
|
|||
withDockerRegistry([ credentialsId: registry_credentials, url: "https://"+registry ]) {
|
||||
echo 'Starting to build docker image'
|
||||
script {
|
||||
def customImage = docker.build(registry+'/'+repo+'/'+project, "--build-arg VERSION=$version --build-arg DATE=$timeStamp .")
|
||||
def customImage = docker.build(registry+'/'+repo+'/'+project, "--pull --build-arg VERSION=$version --build-arg DATE=$timeStamp .")
|
||||
customImage.push(version)
|
||||
customImage.push(version.split(/\./)[0,1].join('.'))
|
||||
customImage.push(version.split(/\./)[0])
|
||||
|
@ -43,8 +43,36 @@ pipeline {
|
|||
}
|
||||
|
||||
post {
|
||||
success {
|
||||
sh """docker rmi -f \$(docker images -q $registry/$repo/$project:$version)"""
|
||||
sh """for image in \$(grep FROM Dockerfile | cut -d ' ' -f 2); do docker rmi -f \$(docker images -q \${image}); done"""
|
||||
}
|
||||
always {
|
||||
emailext body: 'build finished', subject: '[jenkins] docker '+project+': ' + currentBuild.result, to: 'cg@zknt.org', from: 'sysadm@zknt.org', attachLog: true
|
||||
}
|
||||
}
|
||||
options {
|
||||
buildDiscarder(BuildHistoryManager([
|
||||
[
|
||||
conditions: [
|
||||
BuildResult(matchFailure: true)
|
||||
],
|
||||
matchAtMost: 4,
|
||||
continueAfterMatch: false
|
||||
],
|
||||
[
|
||||
conditions: [
|
||||
BuildResult(matchSuccess: true)
|
||||
],
|
||||
matchAtMost: 4,
|
||||
continueAfterMatch: false
|
||||
],
|
||||
[
|
||||
conditions: [
|
||||
BuildResult(matchSuccess: true, matchFailure: true)
|
||||
],
|
||||
actions: [DeleteBuild()]
|
||||
]
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue