forked from jenkins-infra/jenkins.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
105 lines (88 loc) · 3.35 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
/* 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') {
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-ci.org/browse/JENKINS-31386
*/
checkout scm
stage 'Build site'
/* If the slave can't gather resources and build the site in 60 minutes,
* something is very wrong
*/
timeout(60) {
/* Invoke Gradle which has the actual task graph defined inside of it
* for the building of the site
*/
withJavaEnv {
sh './gradlew --console=plain --no-daemon --info --stacktrace'
}
}
stage 'Archive site'
/* The `archive` task inside the Gradle build should be creating a zip file
* which we can use for the deployment of the site. This stage will archive
* that artifact so we can pick it up later
*/
archive 'build/**/*.zip'
/* stash the archived site so we can pull it back out when we deploy */
stash includes: 'build/**/*.zip', name: 'built-site'
}
stage 'Deploy beta site'
node {
/* This Credentials ID is from the `site-deployer` account on
* ci.jenkins-ci.org
*
* Watch https://issues.jenkins-ci.org/browse/JENKINS-32101 for updates
*/
if (env.BRANCH_NAME == 'master') {
sshagent(credentials: ['1d105eb8-fd08-489c-988f-694fd8b658f7']) {
/* Make sure we delete our current directory on this node to make sure
* we're only uploading what we unstash
*/
deleteDir()
unstash 'built-site'
sh 'ls build/archives'
parallel(
eggplant: {
sh 'echo "put build/archives/*.zip archives/" | sftp -o "StrictHostKeyChecking=no" [email protected]'
},
cucumber: {
sh 'echo "put build/archives/*.zip archives/" | sftp -o "StrictHostKeyChecking=no" [email protected]'
})
}
}
}
/* This code shame-lessly copied and pasted from some Jenkinsfile code abayer
wrote for the jenkinsci/jenkins project */
void withJavaEnv(List envVars = [], def body) {
String jdktool = tool name: "jdk7_80", type: 'hudson.model.JDK'
// Set JAVA_HOME, and special PATH variables for the tools we're
// using.
List javaEnv = ["PATH+JDK=${jdktool}/bin", "JAVA_HOME=${jdktool}"]
// Add any additional environment variables.
javaEnv.addAll(envVars)
// Invoke the body closure we're passed within the environment we've created.
withEnv(javaEnv) {
body.call()
}
}
// vim: ft=groovy