-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJenkinsfile
More file actions
54 lines (51 loc) · 2.45 KB
/
Jenkinsfile
File metadata and controls
54 lines (51 loc) · 2.45 KB
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
node {
def nodeBuilder = docker.image("node:8")
nodeBuilder.pull()
try {
stage('Checkout') {
checkout scm
}
stage('Test') {
try {
sh 'yarn run coverage'
junit 'coverage/test-results.xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage/cobertura-coverage.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
} catch (e) {
junit 'coverage/test-results.xml'
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: 'coverage/cobertura-coverage.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
sh 'yarn run postcoverage'
throw e
}
}
} catch (e) {
slackSend color: 'bad', channel: '#codebot', message: "Failed testing ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
throw e
}
if (env.BRANCH_NAME == 'master') {
try {
stage('Yarn Production Install') {
nodeBuilder.inside("-v ${env.WORKSPACE}:/app -u 0:0") {
sh 'yarn install --production'
}
}
docker.withRegistry('https://664537616798.dkr.ecr.us-east-1.amazonaws.com', 'ecr:us-east-1:aws-jenkins-login') {
stage('Build Container') {
myDocker = docker.build("base4-graph:v${env.BUILD_NUMBER}", '.')
}
stage('Push Container') {
myDocker.push("latest");
myDocker.push("v${env.BUILD_NUMBER}");
}
}
stage('Upgrade Container') {
rancher confirm: true, credentialId: 'rancher', endpoint: 'https://rancher.as3.io/v2-beta', environmentId: '1a18', image: "664537616798.dkr.ecr.us-east-1.amazonaws.com/base4-graph:v${env.BUILD_NUMBER}", service: 'base4/graph', environments: '', ports: '', timeout: 180
}
stage('Notify Upgrade') {
slackSend color: 'good', message: "Finished deploying ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
}
} catch (e) {
slackSend color: 'bad', message: "Failed deploying ${env.JOB_NAME} #${env.BUILD_NUMBER} (<${env.BUILD_URL}|View>)"
throw e
}
}
}