-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDeclarative-Jenkinsfile
More file actions
74 lines (68 loc) · 2.93 KB
/
Declarative-Jenkinsfile
File metadata and controls
74 lines (68 loc) · 2.93 KB
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
#!groovy
pipeline {
agent any
environment {
// Three environment variables are needed for DevOps Insights
// IBM_CLOUD_DEVOPS_APP_NAME -> This is the name of the application that shows up in the dashboard
// IBM_CLOUD_DEVOPS_TOOLCHAIN_ID -> This is your toolchain id, for this tutorial the value for it is set in the Jenkins configuration page
// IBM_CLOUD_DEVOPS_API_KEY -> This is the api key for your account that also has access to the toolchain, the value for this is specified in Jenkins credentials.
IBM_CLOUD_DEVOPS_API_KEY = credentials('YOUR_API_KEY_ID')
IBM_CLOUD_DEVOPS_APP_NAME = 'Weather-App-Declarative'
}
stages {
stage('Build') {
steps {
// run your build scripts
sh '''
echo "Build...."
'''
}
// post build section to use "publishBuildRecord" method to publish build record
post {
success {
publishBuildRecord gitBranch: "master", gitCommit: "123234345", gitRepo: "https://test-iam-1", result:"SUCCESS"
}
failure {
publishBuildRecord gitBranch: "master", gitCommit: "123234345", gitRepo: "https://test-iam-1", result:"FAIL"
}
}
}
stage('Upload Unit Test and Code Coverage') {
steps {
sh '''
echo "Upload test results...."
'''
}
// post build section to use "publishTestResult" method to publish test result
post {
always {
publishTestResult type:'unittest', fileLocation: './mocha_pass.json'
publishTestResult type:'code', fileLocation: './istanbul_pass.json'
}
}
}
stage('Gate') {
steps {
// use "evaluateGate" method to leverage IBM Cloud DevOps gate
evaluateGate policy: 'FirstPolicy', forceDecision: 'true'
}
}
stage('Deploy') {
steps {
// Push the Weather App to Bluemix, staging space
sh '''
echo "Deploying...."
'''
}
// post build section to use "publishDeployRecord" method to publish deploy record and notify OTC of stage status
post {
success {
publishDeployRecord environment: "dev", result:"SUCCESS", appUrl: "https://test-iam-app-1"
}
failure {
publishDeployRecord environment: "dev", result:"FAIL", appUrl: "https://test-iam-app-1"
}
}
}
}
}