forked from eclipse-che/che-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
132 lines (118 loc) · 3.1 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
119
120
121
122
123
124
125
126
127
128
129
130
pipeline {
agent {
kubernetes {
label 'che-docs-pod'
yaml """
apiVersion: v1
metadata:
labels:
run: che-docs-pod
name: che-docs-pod
spec:
containers:
- name: jnlp
volumeMounts:
- mountPath: /home/jenkins/.ssh
name: volume-known-hosts
env:
- name: "HOME"
value: "/home/jenkins/agent"
- name: che-docs
image: quay.io/eclipse/che-docs
command:
- cat
tty: true
volumes:
- configMap:
name: known-hosts
name: volume-known-hosts
"""
}
}
environment {
PROJECT_NAME = "che"
PROJECT_BOT_NAME = "CHE Bot"
CI = true
}
triggers { pollSCM('H/10 * * * *')
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
checkoutToSubdirectory('che-docs')
disableConcurrentBuilds()
timeout(time: 15, unit: 'MINUTES')
}
stages {
stage('Checkout www repo (master)') {
when {
branch 'master'
beforeAgent true
}
steps {
milestone 1
container('jnlp') {
dir('www') {
sshagent(['git.eclipse.org-bot-ssh']) {
sh '''
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no" git clone ssh://genie.${PROJECT_NAME}@git.eclipse.org:29418/www.eclipse.org/${PROJECT_NAME}.git .
git checkout master
'''
}
}
}
milestone 2
}
}
stage('Build che-docs website') {
steps {
milestone 21
container('che-docs') {
dir('che-docs') {
sh './tools/environment_docs_gen.sh'
sh './tools/checluster_docs_gen.sh'
sh 'CI=true antora generate antora-playbook.yml --stacktrace'
}
}
milestone 22
}
}
stage('Push to www repo (master)') {
when {
branch 'master'
beforeAgent true
}
steps {
milestone 41
sh 'ls -la'
dir('www') {
sshagent(['git.eclipse.org-bot-ssh']) {
sh '''
cd "${WEBSITE}"
rm -rf docs/
mkdir -p docs
cp -Rvf ../che-docs/build/site/* docs/
git add -A
if ! git diff --cached --exit-code; then
echo "Changes have been detected, publishing to repo 'www.eclipse.org/${PROJECT_NAME}'"
git config --global user.email "${PROJECT_NAME}[email protected]"
git config --global user.name "${PROJECT_BOT_NAME}"
export DOC_COMMIT_MSG=$(git log --oneline --format=%B -n 1 HEAD | tail -1)
git commit -s -m "[docs] ${DOC_COMMIT_MSG}"
git log --graph --abbrev-commit --date=relative -n 5
git push origin HEAD:master
else
echo "No change have been detected since last build, nothing to publish"
fi
'''
}
}
milestone 42
}
}
}
post {
always {
archiveArtifacts artifacts: 'che-docs/build/**', fingerprint: true
}
}
}