-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Jenkinsfile
56 lines (50 loc) · 1.72 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pipeline {
agent {
node { label "docker-host" }
}
environment {
GIT_NAME = "geonetwork-eea"
registry = "eeacms/eea-geonetwork"
default_branch = "eea-4.4.x"
}
stages {
stage ('Docker build and push') {
when {
environment name: 'CHANGE_ID', value: ''
}
steps {
script{
if (env.BRANCH_NAME == env.default_branch ) {
tagName = GIT_COMMIT.take(8)
} else {
tagName = "$BRANCH_NAME"
}
try {
dockerImage = docker.build("$registry:$tagName", "--pull --no-cache --build-arg COMMIT_OR_BRANCH=$tagName ./build-in-docker/")
docker.withRegistry( '', 'eeajenkins' ) {
dockerImage.push()
}
}
finally {
sh "docker rmi $registry:$tagName"
}
}
}
}
}
post {
always {
cleanWs(cleanWhenAborted: true, cleanWhenFailure: true, cleanWhenNotBuilt: true, cleanWhenSuccess: true, cleanWhenUnstable: true, deleteDirs: true)
script {
def url = "${env.BUILD_URL}/display/redirect"
def status = currentBuild.currentResult
def subject = "${status}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${url})"
def details = """<h1>${env.JOB_NAME} - Build #${env.BUILD_NUMBER} - ${status}</h1>
<p>Check console output at <a href="${url}">${env.JOB_BASE_NAME} - #${env.BUILD_NUMBER}</a></p>
"""
emailext (subject: summary, body: details, attachLog: true, compressLog: true, to: '[email protected], [email protected]')
}
}
}
}