-
Notifications
You must be signed in to change notification settings - Fork 37
/
Jenkinsfile
88 lines (86 loc) · 2.91 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
#!groovy
@Library('kanolib') _
def utils;
pipeline {
agent {
label 'ubuntu_18.04_with_docker'
}
stages {
stage('checkout') {
steps {
checkout scm
}
}
stage('install dependencies') {
steps {
script {
docker.image('kanocomputing/node-gyp:10').inside('-u root') {
sh "apk update && apk upgrade && apk add --no-cache bash git openssh"
sh "mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts"
withCredentials([string(credentialsId: 'npm-read-only', variable: 'NPM_TOKEN')]) {
sh "echo \"//registry.npmjs.org/:_authToken=${NPM_TOKEN}\" > .npmrc"
}
sshagent(['read-only-github']) {
sh "yarn"
}
}
}
}
}
stage('build') {
steps {
script {
def e = env.BRANCH_NAME == 'master' ? 'staging' : 'production';
if (env.BRANCH_NAME == "rc") {
e = 'staging'
}
docker.image('node:10-alpine').inside {
sh "yarn build"
sh "yarn build:web --env=${e}"
}
}
}
}
stage('release') {
steps {
script {
def target = "dev"
if (env.BRANCH_NAME != "master" && env.BRANCH_NAME != "rc" && env.BRANCH_NAME != "prod") {
return;
}
if (env.BRANCH_NAME == "rc") {
target = "staging"
}
if (env.BRANCH_NAME == "prod") {
target = "prod"
}
docker.image('ughly/alpine-aws-cli').inside {
withCredentials([[$class: 'AmazonWebServicesCredentialsBinding', accessKeyVariable: 'AWS_ACCESS_KEY_ID', credentialsId: 'kart', secretKeyVariable: 'AWS_SECRET_ACCESS_KEY']]) {
sh "aws s3 rm s3://art-${target}.kano.me --recursive"
sh "aws s3 cp ./out/www s3://art-${target}.kano.me --recursive --acl public-read"
}
}
}
}
}
}
post {
always {
jiraSendBuildInfo site: 'kanocomputing.atlassian.net'
}
regression {
script {
email.notifyCulprits()
}
}
fixed {
script {
email.notifyCulprits()
}
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '20'))
timeout(time: 60, unit: 'MINUTES')
}
}