forked from centreon/centreon-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
62 lines (58 loc) · 2.04 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
pipeline {
agent any
stages {
stage('Install documentation dependencies') {
when {
not { branch 'production' }
}
steps {
echo 'Using Yarn to install dependencies'
sh 'cd .. && sudo apt install curl -y && curl -sL https://deb.nodesource.com/setup_16.x | sudo bash - && sudo apt install nodejs -y'
sh 'yarn install'
}
}
stage('Build documentation') {
when {
not { branch 'production' }
}
steps {
echo 'Using yarn to build documentation'
sh 'yarn build'
sh 'tar czf build.tar.gz build'
archiveArtifacts artifacts: "build.tar.gz"
}
}
stage('Deploy PR to prewiew platform') {
when { changeRequest target: 'staging' }
steps {
timeout(time:2, unit:'HOURS') {
input message: 'Deploy PR to prewiew platform? (Click "Proceed" to continue)'
}
sh 'aws s3 sync --delete build s3://centreon-documentation-preview-pr/ --exclude "robots.txt"'
sh 'aws cloudfront create-invalidation --distribution-id E1JOAJFE0XFP6P --paths "/*"'
}
}
stage('Deploy documentation to staging') {
when { branch 'staging' }
steps {
sh 'rsync -e "ssh -o StrictHostKeyChecking=no" -arzvh --delete build/* [email protected]:/var/www/html/'
//sh 'aws cloudfront create-invalidation --distribution-id ID_DISTRIB_STAGING --paths "/*"'
}
}
stage('Deploy documentation to production') {
when { branch 'production' }
steps {
timeout(time:2, unit:'HOURS') {
input message: 'Deploying to production? (Click "Proceed" to continue)'
}
sh 'ssh -o StrictHostKeyChecking=no [email protected] rsync -arzvh --delete /var/www/html [email protected]:/var/www/'
sh 'aws cloudfront create-invalidation --distribution-id E1CNJDQJ2JT4KZ --paths "/*"'
}
}
}
post {
always {
cleanWs()
}
}
}