forked from IbrahimmAdel/app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
71 lines (58 loc) · 1.73 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
@Library('Jenkins-Shared-Library')_
pipeline {
agent {
// Specifies a label to select an available agent
node {
label 'jenkins-slave'
}
}
environment {
dockerHubCredentialsID = 'DockerHub' // DockerHub credentials ID.
imageName = 'alikhames/java-app' // DockerHub repo/image name.
openshiftCredentialsID = 'openshift' // KubeConfig credentials ID.
nameSpace = 'alikhames'
clusterUrl = 'https://api.ocp-training.ivolve-test.com:6443'
}
stages {
stage('Run Unit Test') {
steps {
script {
runUnitTests
}
}
}
stage('Build and Push Docker Image') {
steps {
script {
buildandPushDockerImage("${dockerHubCredentialsID}", "${imageName}")
}
}
}
stage('Edit new image in deployment.yaml file') {
steps {
script {
dir('oc') {
editNewImage("${imageName}")
}
}
}
}
stage('Deploy on OpenShift Cluster') {
steps {
script {
dir('oc') {
deployOnOc("${openshiftCredentialsID}", "${nameSpace}", "${clusterUrl}")
}
}
}
}
}
post {
success {
echo "${JOB_NAME}-${BUILD_NUMBER} pipeline succeeded"
}
failure {
echo "${JOB_NAME}-${BUILD_NUMBER} pipeline failed"
}
}
}