-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
101 lines (90 loc) · 2.87 KB
/
Copy pathJenkinsfile
File metadata and controls
101 lines (90 loc) · 2.87 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
@Library('java-shared-library') _
pipeline {
agent any
// tools {
// jdk 'jdk-17'
// maven 'maven'
// }
environment {
dockerHubCredentialsID = 'docker'
imageName = 'tabana1/ivolve-grad'
OPENSHIFT_SERVER = 'https://console-openshift-console.apps.ocp-training.ivolve-test.com'
GIT_REPO = 'https://github.com/tabana1/MultiCloudDevOpsProject'
OPENSHIFT_PROJECT = 'mohamedtabana'
OPENSHIFT_CREDENTIALS_ID = 'open-shift-service'
// mysonar-token = 'sonarqube'
SonarHostUrl = 'http://192.168.153.134:9000'
SCANNER_HOME = tool 'sonar-qube'
}
stages {
stage('Run Unit Test') {
steps {
script {
dir('my-app') {
runUnitTests()
}
}
}
}
// stage('Checkout') {
// steps {
// script {
// git branch: 'main', url: 'https://github.com/tabana1/MultiCloudDevOpsProject'
// }
// }
// }
stage('SonarQube CD') {
steps {
script {
dir('my-app') {
// sonarQubeCD(Token_Sonar)
withSonarQubeEnv('sonar-qube') {
sh 'chmod +x gradlew'
sh './gradlew sonar -Dsonar.java.binaries=build/classes'
}
// withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_TOKEN')]) {
// sh """
// chmod +x gradlew
// ./gradlew sonar \
// -Dsonar.projectKey= "java-project" \
// -Dsonar.host.url=${SonarHostUrl} \
// -Dsonar.token=${SONAR_TOKEN} \
// -Dsonar.scm.provider=git \
// -Dsonar.java.binaries=build/classes
// """
// }
}
}
}
}
stage('Build and Push Docker Image') {
steps {
script {
dir('my-app'){
dockerBuildAndPush(
dockerHubCredentialsID, imageName) }
}
}
}
stage('Deploy to OpenShift') {
steps {
script {
dir('openshift'){
openshiftDeploy(OPENSHIFT_CREDENTIALS_ID, imageName)
}
}
}
}
// post {
// always {
// echo 'Pipeline execution completed'
// }
// success {
// echo 'Pipeline executed successfully'
// }
// failure {
// echo 'Pipeline execution failed'
// }
// }
}
}