-
Notifications
You must be signed in to change notification settings - Fork 42
/
Jenkinsfile
87 lines (79 loc) · 2.38 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
void setBuildStatus(String message, String state) {
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: "https://github.com/0xcf/decal-web"],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}
pipeline {
agent {
label 'slave'
}
options {
ansiColor('xterm')
timeout(time: 1, unit: 'HOURS')
disableConcurrentBuilds()
}
stages {
stage('check-gh-trust') {
steps {
checkGitHubAccess('0xcf')
}
}
stage('build') {
steps {
echo "Building branch ${env.BRANCH_NAME}"
sh " test -d _site || mkdir _site"
sh 'docker run --rm --volume=$PWD:/srv/jekyll:Z --volume=$PWD/vendor/bundle:/usr/local/bundle:Z jekyll/jekyll:latest jekyll build'
}
}
stage('deploy') {
parallel {
stage('building master') {
when {
branch 'master'
}
steps {
sshagent (credentials: ['decal-ssh-key']) {
sh 'make deploy'
}
}
}
stage('building branch') {
when {
not {
branch 'master'
}
}
steps {
sshagent (credentials: ['decal-ssh-key']) {
sh "docker run --rm --volume=\$PWD:/srv/jekyll --volume=$PWD/vendor/bundle:/usr/local/bundle:Z jekyll/jekyll:latest jekyll build --baseurl /pr/${env.BRANCH_NAME}"
sh "make deploy DEPLOY_DIR=public_html/pr/${env.BRANCH_NAME}"
script {
if (env.CHANGE_ID) {
ircMessage("New PR to decal-web (https://github.com/0xcf/decal-web/pull/${env.CHANGE_ID}). Hosted at https://decal.ocf.berkeley.edu/pr/${env.BRANCH_NAME}", "decal-web_PR_Notifier", "#decal-comm", "irc.ocf.berkeley.edu:6697")
}
}
}
}
}
}
}
}
post {
always {
node(label: 'slave') {
ircNotification('#decal-spam')
}
}
success {
setBuildStatus("Build succeeded", "SUCCESS");
}
failure {
setBuildStatus("Build failed", "FAILURE");
}
}
}
// vim: ft=groovy