forked from sathishbob/functional-testing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenkins
104 lines (98 loc) · 3.08 KB
/
jenkins
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
102
103
104
def readProb;
def FAILED_STAGE
pipeline {
agent { label 'master'}
tools {
git 'Default'
maven 'mavan-demo'
}
stages {
stage('Preperation'){
steps {
script {
readProb = readProperties file:'config.properties'
FAILED_STAGE=env.STAGE_NAME
Preperation= "${readProb['Preperation']}"
if ("$Preperation" == "yes") {
sh "git config --global user.email [email protected]"
sh "git config --global user.name zippyops"
sh 'git config --global credential.helper cache'
sh 'git config --global credential.helper cache'
sh 'rm -rf devsecopscodebase'
}
else {
echo "Skipped"
}
}
}
}
stage('Git Pull'){
steps { dir("${readProb['Project_name']}"){
git branch: "${readProb['branch']}", credentialsId: "${readProb['credentials']}", url: "${readProb['git.url']}"
}
}
}
stage('SonarQube analysis') {
steps {
script {
scannerHome = tool 'sonarqube';
FAILED_STAGE=env.STAGE_NAME
SonarQube= "${readProb['SonarQube_Analysis']}"
if ("$SonarQube" == "yes") {
withSonarQubeEnv('sonarqube') {
sh "${scannerHome}/bin/sonar-scanner -Dsonar.projectKey=${readProb['sonar_projectKey']} -Dsonar.projectName=${readProb['sonar_projectName']} -Dsonar.projectVersion=${readProb['sonar_projectVersion']} -Dsonar.projectBaseDir=${readProb['sonar_projectBaseDir']} -Dsonar.sources=${readProb['sonar_sources']} -Dsonar.java.binaries=${readProb['sonar_binaries']}"
}
}
else {
echo "Skipped"
}
}
}
}
stage("Sonarqube Quality Gate") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
Quality= "${readProb['SonarQube_Quality']}"
if ("$Quality" == "yes") {
timeout(time: 1, unit: 'HOURS') {
waitForQualityGate abortPipeline: true
}
}
else {
echo "skipped"
}
}
}
}
stage("test") {
steps {
script {
FAILED_STAGE=env.STAGE_NAME
build= "${readProb['Build']}"
if ("$build" == "yes") {
sh """
cd devsecopscodebase/
mvn clean test
"""
}
else {
echo "Skipped"
}
}
}
}
}
post {
success {
publishHTML target: [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'devsecopscodebase/TestReport',
reportFiles: 'TestReport.html',
reportName: 'Dev_Testng_Report'
]
}
}
}