forked from eclipse-che/che-docs
/
Jenkinsfile
140 lines (135 loc) · 3.51 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
131
132
133
134
135
136
137
138
139
140
/* groovylint-disable NestedBlockDepth */
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"
resources:
limits:
memory: "512Mi"
cpu: "100m"
requests:
memory: "512Mi"
cpu: "100m"
- name: che-docs
image: quay.io/eclipse/che-docs
command:
- cat
resources:
limits:
memory: "512Mi"
cpu: "100m"
requests:
memory: "512Mi"
cpu: "100m"
tty: true
volumes:
- configMap:
name: known-hosts
name: volume-known-hosts
'''
}
}
environment {
PROJECT_NAME = 'che'
PROJECT_BOT_NAME = 'CHE Bot'
CI = true
}
triggers { cron('@daily')
// The Jenkins Pipeline builds Eclipse Che documentation for the publication
// to Eclipse website https://www.eclipse.org/che/docs/.
//
// It is:
// * Executing the build from the *Execution branch*.
// * Using the content from the *Publication branches*.
// * Pushing the build artifacts to the `che` repository on Eclipse Git server.
//
// Eclipse infrastructure then publishes to Eclipse website: https://www.eclipse.org/che/docs/.
//
// Execution branch::
//
// The build runs on a branch containing at least the `Jenkinsfile` and `antora-playbook.yml` files.
// It does not need to run at all on other branches.
// By convention: restrict the build to the `main`, `master` and `publication` branches.
//
// Publication branch(es)::
//
// The build is using the content from the publication branch(es) defined in the `antora-playbook.yml` file.
//
// Triggers::
//
// Ideally, run the build when a change in the publication branch happened.
// But it impossible to implement in current context with the available
// `pollSCM` or `upstream` triggers https://www.jenkins.io/doc/book/pipeline/syntax/#triggers
// It would be possible to implement using the `upstream` trigger with a dedicated
// Jenkins job for the Publication branch, and a dedicated Jenkins job for the Execution branch.
// Pragmatic solution: run daily with the `cron` trigger.
//
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
checkoutToSubdirectory('che-docs')
disableConcurrentBuilds(abortPrevious: true)
timeout(time: 30, unit: 'MINUTES')
}
stages {
stage('Build che-docs website') {
when {
anyOf {
branch 'main'
branch 'master'
branch 'publication'
}
beforeAgent true
}
steps {
milestone 21
container('che-docs') {
dir('che-docs') {
sh './tools/build-for-publication.sh'
}
}
milestone 22
}
post {
always {
archiveArtifacts artifacts: 'che-docs/build/**', fingerprint: true
}
}
}
stage('Push to Eclipse repository') {
when {
anyOf {
branch 'main'
branch 'master'
branch 'publication'
}
beforeAgent true
}
steps {
milestone 41
sh 'ls -la'
dir('www') {
sshagent(['git.eclipse.org-bot-ssh']) {
sh '../che-docs/tools/push-to-eclipse-repository.sh'
}
}
milestone 42
}
}
}
}