forked from eclipse-cognicrypt/hugo-website-sources
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
88 lines (84 loc) · 2.13 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
pipeline {
agent {
kubernetes {
label 'hugo-agent'
yaml """
apiVersion: v1
metadata:
labels:
run: hugo
name: hugo-pod
spec:
containers:
- name: hugo
image: eclipsecbi/hugo:0.42.1
command:
- cat
tty: true
- name: jnlp
volumeMounts:
- name: volume-known-hosts
mountPath: /home/jenkins/.ssh
- name: "jenkins-home"
mountPath: "/home/jenkins"
readOnly: false
volumes:
- name: volume-known-hosts
configMap:
name: known-hosts
- name: "jenkins-home"
emptyDir: {}
"""
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
checkoutToSubdirectory('hugo')
disableConcurrentBuilds()
}
triggers {
pollSCM('H/5 * * * *')
}
stages {
stage('Checkout www repo') {
steps {
dir('www') {
git branch: 'master',
url: 'ssh://[email protected]:29418/www.eclipse.org/cognicrypt.git',
credentialsId: 'git.eclipse.org-bot-ssh'
}
}
}
stage('Build website with Hugo') {
steps {
container('hugo') {
dir('hugo') {
sh 'hugo -b https://www.eclipse.org/cognicrypt/'
}
}
}
}
stage('Push to master branch') {
steps {
sh 'cp -Rvf hugo/public/* www/'
dir('www') {
sshagent(['git.eclipse.org-bot-ssh']) {
sh '''
git add -A
if ! git diff --cached --exit-code; then
echo "Changes have been detected, publishing to repo 'www.eclipse.org/cognicrypt'"
git config --global user.email "[email protected]"
git config --global user.name "Cognicrypt Bot"
git commit -m "Website build ${JOB_NAME}-${BUILD_NUMBER}"
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
'''
}
}
}
}
}
}