forked from bcgov/nrts-prc-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile - master
79 lines (75 loc) · 2.34 KB
/
Jenkinsfile - master
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
def sonarqubePodLabel = "prc-public-${UUID.randomUUID().toString()}"
podTemplate(label: sonarqubePodLabel, name: sonarqubePodLabel, serviceAccount: 'jenkins', cloud: 'openshift', containers: [
containerTemplate(
name: 'jnlp',
image: '172.50.0.2:5000/openshift/jenkins-slave-python3nodejs',
resourceRequestCpu: '500m',
resourceLimitCpu: '1000m',
resourceRequestMemory: '1Gi',
resourceLimitMemory: '4Gi',
workingDir: '/tmp',
command: '',
args: '${computer.jnlpmac} ${computer.name}',
envVars: [
envVar(key: 'SONARQUBE_URL', value: 'https://sonarqube-prc-tools.pathfinder.gov.bc.ca')
]
)
]) {
node(sonarqubePodLabel) {
stage('checkout code') {
checkout scm
}
stage('exeucte sonar') {
dir('sonar-runner') {
try {
sh 'npm install typescript && ./gradlew sonarqube -Dsonar.host.url=https://sonarqube-prc-tools.pathfinder.gov.bc.ca -Dsonar.verbose=true --stacktrace --info'
} finally {
}
}
}
}
}
pipeline {
agent any
stages {
stage('Building: public (master branch)') {
steps {
script {
try {
echo "Building: ${env.JOB_NAME} #${env.BUILD_ID}"
notifyBuild("Building: ${env.JOB_NAME} #${env.BUILD_ID}", "YELLOW")
openshiftBuild bldCfg: 'angular-on-nginx-master-build-angular-app-build', showBuildLogs: 'true'
} catch (e) {
notifyBuild("BUILD ${env.JOB_NAME} #${env.BUILD_ID} ABORTED", "RED")
error('Stopping early…')
}
}
}
}
stage('Deploying: public (master branch)') {
steps {
script {
try {
notifyBuild("Deploying: ${env.JOB_NAME} #${env.BUILD_ID}", "YELLOW")
openshiftBuild bldCfg: 'angular-on-nginx-master-build', showBuildLogs: 'true'
} catch (e) {
notifyBuild("BUILD ${env.JOB_NAME} #${env.BUILD_ID} ABORTED", "RED")
error('Stopping early…')
}
notifyBuild("Deployed ${env.JOB_NAME} #${env.BUILD_ID}", "GREEN")
}
}
}
}
}
def notifyBuild(String msg = '', String colour = 'GREEN') {
if (colour == 'YELLOW') {
colorCode = '#FFFF00'
} else if (colour == 'GREEN') {
colorCode = '#00FF00'
} else {
colorCode = '#FF0000'
}
// Send notifications
slackSend (color: colorCode, message: msg)
}