forked from jenkins-infra/jenkins.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
123 lines (109 loc) · 4.09 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
#!/usr/bin/env groovy
/* Only keep the 10 most recent builds. */
def projectProperties = [
[$class: 'BuildDiscarderProperty',strategy: [$class: 'LogRotator', numToKeepStr: '5']],
]
def imageName = 'jenkinsciinfra/jenkinsio'
if (!env.CHANGE_ID) {
if (env.BRANCH_NAME == null) {
projectProperties.add(pipelineTriggers([cron('H/30 * * * *'), pollSCM('H/5 * * * *')]))
projectProperties.add(disableConcurrentBuilds())
}
}
properties(projectProperties)
/* Assuming that wherever we're going to build, we have nodes labelled with
* "Docker" so we can have our own isolated build environment
*/
node('docker&&linux') {
stage('Clean workspace') {
/* Running on a fresh Docker instance makes this redundant, but just in
* case the host isn't configured to give us a new Docker image for every
* build, make sure we clean things before we do anything
*/
deleteDir()
sh 'ls -lah'
}
stage('Checkout source') {
/*
* For a standalone workflow script, we would use the `git` step
*
*
* git url: 'git://github.com/jenkinsci/jenkins.io',
* branch: 'master'
*/
/*
* Represents the SCM configuration in a "Workflow from SCM" project build. Use checkout
* scm to check out sources matching Jenkinsfile with the SCM details from
* the build that is executing this Jenkinsfile.
*
* when not in multibranch: https://issues.jenkins.io/browse/JENKINS-31386
*/
checkout scm
}
stage('Checks') {
/* The Jenkins which deploys doesn't use multibranch or GitHub Org Folders.
* Checks are advisory only.
* They are intentionally skipped when preparing a deployment.
*/
if (!infra.isTrusted() && env.BRANCH_NAME != null) {
sh 'make check'
recordIssues(tools: [checkStyle(id: 'typos', name: 'Typos', pattern: 'checkstyle.xml')],
qualityGates: [[threshold: 1, type: 'TOTAL', unstable: true]])
}
}
stage('Build site') {
/* If the agent can't gather resources and build the site in 60 minutes,
* something is very wrong
*/
timeout(60) {
sh '''#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o xtrace
make all
illegal_filename="$( find . -name '*[<>]*' )"
if [[ -n "$illegal_filename" ]] ; then
echo "Failing build due to illegal filename:" >&2
echo "$illegal_filename" >&2
exit 1
fi
'''
}
}
/* The Jenkins which deploys doesn't use multibranch or GitHub Org Folders.
*/
if (infra.isTrusted() && env.BRANCH_NAME == null) {
stage('Publish site') {
infra.withFileShareServicePrincipal([
servicePrincipalCredentialsId: 'trustedci_jenkinsio_fileshare_serviceprincipal_writer',
fileShare: 'jenkins-io',
fileShareStorageAccount: 'jenkinsio'
]) {
sh '''
# Don't output sensitive information
set +x
# Synchronize the File Share content
azcopy sync \
--skip-version-check \
--recursive=true\
--delete-destination=true \
--compare-hash=MD5 \
--put-md5 \
--local-hash-storage-mode=HiddenFiles \
./build/_site/ "${FILESHARE_SIGNED_URL}"
# Retrieve azcopy logs to archive them
cat /home/jenkins/.azcopy/*.log > azcopy.log
'''
archiveArtifacts 'azcopy.log'
}
}
stage('Purge cached CSS') {
sh '''
curl --request PURGE https://www.jenkins.io/css/jenkins.css
curl --request PURGE https://www.jenkins.io/stylesheets/styles.css
'''
}
}
}
// vim: ft=groovy