-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathJenkinsfile
88 lines (79 loc) · 2.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
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
pipeline {
agent {
label 'docker'
}
parameters {
booleanParam(name: 'DEPLOY_STAGING', defaultValue: false, description: 'Deploy to index.staging.scheme.org')
booleanParam(name: 'DEPLOY_PROD', defaultValue: false, description: 'Deploy to index.scheme.org')
}
stages {
stage('Checkout') {
steps {
git changelog: true, branch: "${BRANCH_NAME}", url: 'https://github.com/schemeorg-community/index.scheme.org'
}
}
stage('Build') {
agent {
docker {
image 'docker:20.10.24-cli'
args "-u root"
reuseNode true
}
}
steps {
sh '''
docker build -f ./build/Dockerfile . -t scheme-index:latest
docker create --name dummy scheme-index:latest
docker cp dummy:/schemeindex.zip ./schemeindex.zip
docker rm -f dummy
'''
}
}
stage('Deploy staging') {
agent {
dockerfile {
filename './deploy/rsync.Dockerfile'
reuseNode true
}
}
when {
expression {
return params.DEPLOY_STAGING
}
}
steps {
sshagent(credentials: ['index_staging_tuonela_ssh']) {
sh '''
mkdir ~/.ssh
ssh-keyscan -t rsa tuonela.scheme.org >> ~/.ssh/known_hosts
rsync schemeindex.zip [email protected]:/staging/index/update/schemeindex.zip
ssh [email protected] 'cd ~ ; bash install-update.sh'
'''
}
}
}
stage('Deploy production') {
agent {
dockerfile {
filename './deploy/rsync.Dockerfile'
reuseNode true
}
}
when {
expression {
return params.DEPLOY_PROD
}
}
steps {
sshagent(credentials: ['index_tuonela_ssh']) {
sh '''
mkdir ~/.ssh
ssh-keyscan -t rsa tuonela.scheme.org >> ~/.ssh/known_hosts
rsync schemeindex.zip [email protected]:/production/index/update/schemeindex.zip
ssh [email protected] 'cd ~ ; bash install-update.sh'
'''
}
}
}
}
}