-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
78 lines (69 loc) · 2.24 KB
/
Jenkinsfile
File metadata and controls
78 lines (69 loc) · 2.24 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
75
76
77
78
library identifier: "pipeline-library@v1.5",
retriever: modernSCM(
[
$class: "GitSCMSource",
remote: "https://github.com/redhat-cop/pipeline-library.git"
]
)
openshift.withCluster() {
env.NAMESPACE = openshift.project()
env.APP_NAME = "survey-service-node"
echo "Starting Pipeline for ${APP_NAME}..."
env.DEV = env.NAMESPACE.replaceAll(/-ci-cd/, '-dev')
env.TEST = env.NAMESPACE.replaceAll(/-ci-cd/, '-test')
env.DEMO = env.NAMESPACE.replaceAll(/-ci-cd/, '-demo')
}
pipeline {
// Use Jenkins Maven slave
// Jenkins will dynamically provision this as OpenShift Pod
// All the TESTs and steps of this Pipeline will be executed on this Pod
// After Pipeline completes the Pod is killed so every run will have clean
// workspace
agent {
label 'jenkins-slave-npm'
}
// Pipeline TESTs start here
// Requeres at least one TEST
stages {
// Run NPM build, skipping tests
stage('Build'){
steps {
sh "npm install"
// sh "npm run build" // Build step is not required because there is no transpiling needed
}
}
// Run NPM unit tests
stage('Unit Test') { // No tests have yet been written
steps {
sh "echo NO TESTS AVAILABLE YET" // "npm run test"
}
}
// Build Container Image using the artifacts produced in previous stages
stage('Build Container Image'){
steps {
sh """
mkdir -p oc-build
cp package.json oc-build/
cp app.js oc-build/
cp -fr src oc-build/
cp -fr node_modules oc-build/
"""
// Build container image using local Openshift cluster
// Giving all the artifacts to OpenShift Binary Build
// This places your artifacts into right location inside your S2I image
// if the S2I image supports it.
binaryBuild(projectName: env.NAMESPACE, buildConfigName: env.APP_NAME, buildFromPath: 'oc-build')
}
}
stage('Promote from Build to Dev') {
steps {
tagImage(sourceImageName: env.APP_NAME, sourceImagePath: env.NAMESPACE, toImagePath: env.DEV, toImageName: 'node-service')
}
}
stage('Verify Deployment to Dev') {
steps {
verifyDeployment(projectName: env.DEV, targetApp: 'node-service')
}
}
}
}