forked from herber523/devopsdays-2018
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
68 lines (64 loc) · 2.54 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
57
58
59
60
61
62
63
64
65
66
67
68
pipeline {
agent { node { label 'compute' } }
environment {
// code for manual case
//CODE = git(branch: 'master', credentialsId: '2018devopsday', url: '[email protected]:trendmicro/devopsdays-2018.git')
VERSION = sh (script: './bin/version.sh', returnStdout: true).trim()
APP_NAME = 'devopsdays'
REGISTRY = 'docker.trendops.co'
}
stages{
stage('Build'){
steps {
sh 'docker build --pull -t ${REGISTRY}/ops/${APP_NAME} .'
sh 'docker tag ${REGISTRY}/ops/${APP_NAME}:latest ${REGISTRY}/ops/${APP_NAME}:${VERSION}'
sh 'docker push ${REGISTRY}/ops/${APP_NAME}'
sh 'docker push ${REGISTRY}/ops/${APP_NAME}:${VERSION}'
sh 'docker rmi ${REGISTRY}/ops/${APP_NAME} || true'
}
}
stage('Unit Test'){
steps {
echo 'TBD'
}
}
stage('Deploy'){
steps {
echo "Deploying..."
sshagent (credentials: ['2018devopsday']) {
sh 'ssh -o StrictHostKeyChecking=no [email protected] deploy'
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
}
changed {
echo 'Things were different before...'
}
success {
emailext(attachLog: true,
body: '''${SCRIPT, template="groovy-html.template"}''',
replyTo: '[email protected]',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],[$class: 'RequesterRecipientProvider']],
subject: "'${currentBuild.fullDisplayName} ${currentBuild.currentResult}'",
to: '[email protected]')
deleteDir() /* clean up our workspace */
}
unstable {
echo 'I am unstable :/'
}
failure {
echo 'I failed :('
emailext(attachLog: true,
body: '''${SCRIPT, template="groovy-html.template"}''',
replyTo: '[email protected]',
recipientProviders: [[$class: 'DevelopersRecipientProvider'],[$class: 'RequesterRecipientProvider']],
subject: "'${currentBuild.fullDisplayName} ${currentBuild.currentResult}'",
to: '[email protected]')
deleteDir() /* clean up our workspace */
}
}
}