-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
94 lines (94 loc) · 3.88 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
pipeline {
parameters {
choice(name: 'deploy_selection', description: 'Build and deploy build to studyathome.technikum-wien.at:8090-8092 or Deploy from studyathome.technikum-wien.at to github.io', choices: ['studyathome.technikum-wien.at','github.io'])
// booleanParam(name: 'deploy', defaultValue: true, description: 'Deploy build to studyathome.technikum-wien.at:8090-8092')
// booleanParam(name: 'deploy_io_exchange', defaultValue: false, description: 'Exchange deployed build to github.io with previous commit')
choice(name: 'GH_TOKEN_ID', description: 'Id of github user token credential stored in Jenkins credentials. Required for deployent to github.io', choices:['GH-TOKEN-DEINHOFER'])
choice(name: 'dest', description: 'Destination/Source folder: studyathome.technikum-wien.at:8090-8092, The ports map to the choices in the given order', choices: ['asterics-web-production','asterics-web-devlinux', 'asterics-web-devwindows'])
// choice(name: 'agent', description: 'Agent', choices: ['Linux', 'Win'])
// choice(name: 'image', description: 'Docker Image', choices: ['node:10', 'node:11'])
gitParameter(name: 'BRANCH', branchFilter: 'origin.*?/(.*)', defaultValue: 'master', type: 'PT_BRANCH_TAG', useRepository: 'asterics-docs')
}
triggers {
// pollSCM('H/15 * * * *')
//should be trigger from 6 to 18 every 6hours (at 6h at 12h at 18h)
cron('0 6-18/6 * * *')
}
agent none
stages {
stage('Cleanup') {
agent {
label 'Linux'
}
steps {
deleteDir()
}
}
stage('Build') {
when {
equals expected: 'studyathome.technikum-wien.at', actual: params.deploy_selection
}
agent {
docker {
image 'node:10'
label 'Linux'
}
}
steps {
sh '''
yarn --no-lockfile
yarn docs clean
yarn docs init
yarn docs setup --verbose
yarn build
'''
}
}
stage('Deploy studyathome:8090-8092') {
when {
equals expected: 'studyathome.technikum-wien.at', actual: params.deploy_selection
}
agent {
label 'Linux'
}
environment {
SERVER = credentials('server')
}
steps {
script {
def remote = [ name: 'studyathome', host: 'studyathome.technikum-wien.at', user: env.SERVER_USR, password: env.SERVER_PSW, allowAnyHosts: true ]
sshRemove remote: remote, path: "/var/www/html/dist", failOnError: false
sshRemove remote: remote, path: "/var/www/html/${params.dest}", failOnError: false
sshPut remote: remote, from: 'dist', into: "/var/www/html/"
sshCommand remote: remote, command: "mv /var/www/html/dist /var/www/html/${params.dest}"
}
}
}
stage('Deploy: Github IO') {
when {
equals expected: 'github.io', actual: params.deploy_selection
}
agent {
label 'Linux'
}
environment {
SERVER = credentials('server')
GH_TOKEN=credentials("${params.GH_TOKEN_ID}")
}
steps {
script {
def remote = [ name: 'studyathome', host: 'studyathome.technikum-wien.at', user: env.SERVER_USR, password: env.SERVER_PSW, allowAnyHosts: true ]
sshCommand remote: remote, command: "DEPLOY_SOURCE=/var/www/html/${params.dest}/ DEPLOY_REPO_PATH=asterics/asterics-docs.git DEPLOY_CNAME=www.asterics.eu DEPLOY_GH_TOKEN=${GH_TOKEN} /home/study/deployment-utils/deploy-ghpages.sh"
}
}
}
}
// post {
// failure {
// mail to: [email protected], subject: "The asterics-docs Pipeline with build id ${BUILD_ID} failed :("
// }
// success {
// mail to: [email protected], subject: "The asterics-docs Pipeline with build id ${BUILD_ID} was successful :-)"
// }
// }
}