-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
121 lines (117 loc) · 4.05 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
pipeline {
agent { label 'docker' }
environment {
IMAGE_TAG = env.BRANCH_NAME.replaceFirst('^master$', 'latest')
GITLAB_TOKEN = credentials('process-flow-gitlab-token')
SCANNER_HOME = tool name: 'SonarQube Scanner 3', type: 'hudson.plugins.sonar.SonarRunnerInstallation'
}
options {
gitLabConnection('gitlab')
buildDiscarder(logRotator(numToKeepStr: '10'))
}
triggers {
gitlab(triggerOnPush: true, triggerOnMergeRequest: true, branchFilterType: 'All', secretToken: env.GITLAB_TOKEN)
cron(env.VISUALIZATION_CRON)
}
post {
failure {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'failed'
}
aborted {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'canceled'
}
}
stages {
stage('Start') {
when {
not {
triggeredBy 'TimerTrigger'
}
}
steps {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'running'
}
}
stage('Build') {
steps {
sh 'docker build -t $DOCKER_REGISTRY/gros-process-flow:$IMAGE_TAG . --build-arg NPM_REGISTRY=$NPM_REGISTRY'
}
}
stage('SonarQube Analysis') {
when {
not {
triggeredBy 'TimerTrigger'
}
}
steps {
withSonarQubeEnv('SonarQube') {
sh '${SCANNER_HOME}/bin/sonar-scanner -Dsonar.projectKey=process-flow:$BRANCH_NAME -Dsonar.projectName="Process Flow $BRANCH_NAME"'
}
}
}
stage('Push') {
when { branch 'master' }
steps {
sh 'docker push $DOCKER_REGISTRY/gros-process-flow:latest'
}
}
stage('Collect') {
when {
anyOf {
branch 'master'
not {
triggeredBy 'TimerTrigger'
}
}
}
agent {
docker {
image "${env.DOCKER_REGISTRY}/gros-data-analysis-dashboard"
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'data-analysis-config', variable: 'ANALYSIS_CONFIGURATION')]) {
sh '/bin/bash -c "rm -rf $PWD/output && mkdir $PWD/output && cd /home/docker && Rscript report.r $REPORT_PARAMS --report story_flow --projects main --log INFO --config $ANALYSIS_CONFIGURATION --output $PWD/output"'
}
}
}
stage('Visualize') {
when {
anyOf {
branch 'master'
not {
triggeredBy 'TimerTrigger'
}
}
}
agent {
docker {
image "${env.DOCKER_REGISTRY}/gros-process-flow:${env.IMAGE_TAG}"
reuseNode true
}
}
steps {
withCredentials([file(credentialsId: 'process-flow-config', variable: 'PROCESS_FLOW_CONFIGURATION')]) {
sh 'rm -rf public/data/'
sh 'mkdir -p public/'
sh 'mv output/ public/data/'
sh 'rm -rf node_modules/'
sh 'ln -s /usr/src/app/node_modules .'
sh 'MIX_FILE=$WORKSPACE/webpack.mix.js npm run production'
}
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'public', reportFiles: 'index.html', reportName: 'Visualization', reportTitles: ''])
}
}
stage('Status') {
when {
not {
triggeredBy 'TimerTrigger'
}
}
steps {
updateGitlabCommitStatus name: env.JOB_NAME, state: 'success'
}
}
}
}