-
Notifications
You must be signed in to change notification settings - Fork 170
/
Jenkinsfile
118 lines (104 loc) · 3.94 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
def NODE = 'git-websites'
def STOP_SQUASH_AT = '5570b6e2e57afb5f0a8f78f9bf9c33bd6f16aaed'
pipeline {
agent {
label "$NODE"
}
options {
buildDiscarder(
logRotator(artifactNumToKeepStr: '5', numToKeepStr: '10')
)
checkoutToSubdirectory('camel-website')
}
environment {
ANTORA_CACHE_DIR = "$WORKSPACE/.antora-cache"
CAMEL_ENV = 'production'
GITHUB = credentials('399061d0-5ab5-4142-a186-a52081fef742') // asf-ci credential
HUGO_CACHEDIR = "$WORKSPACE/.hugo-cache"
}
stages {
stage('Website') {
agent {
dockerfile {
dir 'camel-website'
label "$NODE"
reuseNode true
args '-u root'
}
}
environment {
HOME = "$WORKSPACE"
}
steps {
sh "cd $WORKSPACE/camel-website && yarn clean; HUGO_PARAMS_GitHubUsername=$GITHUB_USR HUGO_PARAMS_GitHubToken=$GITHUB_PSW yarn build-all"
}
}
stage('Setup') {
steps {
sh "$WORKSPACE/camel-website/support/docker-pipe.sh $WORKSPACE/docker-pipe &"
}
}
stage('Checks') {
agent {
dockerfile {
dir 'camel-website'
label "$NODE"
reuseNode true
args "-u root -v $WORKSPACE/docker-pipe/docker:/usr/bin/docker"
}
}
environment {
HOME = "$WORKSPACE"
}
steps {
sh "cd $WORKSPACE/camel-website && yarn checks"
}
}
stage('Deploy') {
when {
branch 'main'
}
steps {
dir('deploy/live') {
deleteDir()
sh 'git clone -b asf-site https://gitbox.apache.org/repos/asf/camel-website-pub.git .'
sh "git -c core.editor='sed -i 2,/\$(git log --skip=9 -1 --pretty=format:%h)/s/^pick/squash/' rebase -q --interactive $STOP_SQUASH_AT" // squash all but initial and last 9 commits
sh 'git rm -q -r *'
sh "cp -R $WORKSPACE/camel-website/public/. ."
sh 'git add .'
sh 'git commit -m "Website updated to $GIT_COMMIT"'
sh 'git push --force origin asf-site'
}
}
}
}
post {
always {
sh "[ -x $WORKSPACE/docker-pipe/teardown.sh ] && $WORKSPACE/docker-pipe/teardown.sh || true"
}
fixed {
mail subject: 'Website build status', body: "🥳 Build succeeded!", to: 'camel-website.874fb06555c2b4407efde9f9a3b13c13.show-sender@streams.zulipchat.com'
}
unsuccessful {
mail subject: 'Website build status', body: "😞 Build failed. Please have a look at the build output at: ${env.BUILD_URL}", to: 'camel-website.874fb06555c2b4407efde9f9a3b13c13.show-sender@streams.zulipchat.com'
}
}
}