forked from ittech17/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
91 lines (85 loc) · 2.79 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
pipeline {
agent none
stages {
stage('Build staging') {
when {
not {
branch 'master'
}
}
agent {
dockerfile {
filename 'Dockerfile'
}
}
steps {
sh "mkdir -p _site/${env.BRANCH_NAME}"
sh 'bundle exec jekyll clean'
sh "bundle exec jekyll build --baseurl /${env.BRANCH_NAME} --destination _site/${env.BRANCH_NAME}"
stash includes: '_site/**/*', name: '_site'
}
}
stage('Deploy staging') {
when {
not {
branch 'master'
}
}
agent {
docker {
image 'node'
args '-v /$HOME/docker-cache-node:/tmp/docker-cache-node -e "HOME=/tmp/docker-cache-node"'
}
}
steps {
unstash '_site'
withAWS(region: 'us-east-1', credentials: 'aws-docs-staging') {
sh "npm install && cd _site && node ../deploy.js docs-staging.katalon.com ${env.BRANCH_NAME}"
}
}
post {
always {
withAWS(region: 'us-east-1', credentials: 'aws-docs-staging') {
s3Upload(file:'robots.txt', bucket:'docs-staging.katalon.com', path:'', acl:'PublicRead')
}
}
}
}
stage('Build production') {
when { branch 'master' }
agent {
dockerfile {
filename 'Dockerfile'
}
}
steps {
sh 'bundle exec jekyll clean'
sh 'bundle exec jekyll build --config _config.yml,_config_prod.yml'
sh 'rm -rfv _site/robots.txt'
}
post {
success {
withAWS(region: 'us-east-1', credentials: 'aws-docs-staging') {
s3Upload(file:'_site', bucket:'docs.katalon.com', path:'', acl:'PublicRead')
cfInvalidate(distribution:'E39AGUOIPSZ2OA', paths:['/*'])
}
}
}
}
stage('Index production') {
when { branch 'master' }
agent {
dockerfile {
filename 'Dockerfile'
}
}
environment {
ALGOLIA_API_KEY = credentials('algolia-api-key')
}
steps {
sh 'bundle exec jekyll clean'
sh 'bundle exec jekyll algolia --config _config.yml,_config_prod.yml --verbose'
}
}
}
}