-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
131 lines (122 loc) · 4.78 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
pipeline {
agent none
environment {
PIPELINE_VERSION = build.pipelineVersion()
REPOSITORY_NAME = 'projectaanvraag-api'
}
stages {
stage('Pre build') {
steps {
setBuildDisplayName to: env.PIPELINE_VERSION
sendBuildNotification()
}
}
stage('Setup and build') {
agent { label 'ubuntu && 16.04 && php7.1' }
environment {
GIT_SHORT_COMMIT = build.shortCommitRef()
ARTIFACT_VERSION = "${env.PIPELINE_VERSION}" + '+sha.' + "${env.GIT_SHORT_COMMIT}"
}
stages {
stage('Setup') {
steps {
sh label: 'Install rubygems', script: 'bundle install --deployment'
}
}
stage('Build') {
steps {
sh label: 'Build binaries', script: 'bundle exec rake projectaanvraag-api:build'
}
}
stage('Build artifact') {
steps {
sh label: 'Build artifact', script: "bundle exec rake projectaanvraag-api:build_artifact ARTIFACT_VERSION=${env.ARTIFACT_VERSION}"
archiveArtifacts artifacts: "pkg/*${env.ARTIFACT_VERSION}*.deb", onlyIfSuccessful: true
}
}
}
post {
cleanup {
cleanWs()
}
}
}
stage('Upload artifact') {
agent any
options { skipDefaultCheckout() }
steps {
copyArtifacts filter: 'pkg/*.deb', projectName: env.JOB_NAME, flatten: true, selector: specific(env.BUILD_NUMBER)
uploadAptlyArtifacts artifacts: '*.deb', repository: env.REPOSITORY_NAME
createAptlySnapshot name: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", repository: env.REPOSITORY_NAME
}
post {
cleanup {
cleanWs()
}
}
}
stage('Deploy to development') {
agent any
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'development'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
}
}
stage('Deploy to testing') {
agent any
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'testing'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'projectaanvraag-web-test02'
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
}
}
stage('Deploy to production') {
input { message "Deploy to Production?" }
agent any
options { skipDefaultCheckout() }
environment {
APPLICATION_ENVIRONMENT = 'production'
}
steps {
publishAptlySnapshot snapshotName: "${env.REPOSITORY_NAME}-${env.PIPELINE_VERSION}", publishTarget: "${env.REPOSITORY_NAME}-${env.APPLICATION_ENVIRONMENT}", distributions: 'xenial'
triggerDeployment nodeName: 'projectaanvraag-web-prod02'
}
post {
always {
sendBuildNotification to: '#upw-ops', message: "Pipeline <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${currentBuild.displayName}]>: deployed to *${env.APPLICATION_ENVIRONMENT}*"
}
cleanup {
cleanupAptlySnapshots repository: env.REPOSITORY_NAME
}
}
}
stage('Tag release') {
agent { label 'ubuntu && 16.04' }
steps {
copyArtifacts filter: 'pkg/*.deb', projectName: env.JOB_NAME, flatten: true, selector: specific(env.BUILD_NUMBER)
tagRelease commitHash: artifact.metadata(artifactFilter: '*.deb', field: 'git-ref')
}
post {
cleanup {
cleanWs()
}
}
}
}
post {
always {
sendBuildNotification()
}
}
}