-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
68 lines (67 loc) · 1.95 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
pipeline {
agent {
docker {
image 'maven:3.9.5-amazoncorretto-17-al2023'
args '-v /root/.m2:/root/.m2 -v /var/run/docker.sock:/var/run/docker.sock'
}
}
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
environment {
DOCKERHUB_CREDENTIALS = credentials('dockerhub')
}
stages {
stage('SonarQube Analysis') {
steps {
withSonarQubeEnv('SonarQube') {
sh "mvn -f ./YouQuiz/pom.xml sonar:sonar -Dsonar.login=sqa_f048cba3b4e880b1d7557d449082c257c906ddb8 -Dsonar.java.binaries=target/classes"
}
}
}
stage('Quality Gate') {
steps {
timeout(time: 1, unit: 'HOURS') {
script {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage('Build') {
steps {
echo "Building.."
script {
sh '''
mvn -f ./YouQuiz/pom.xml -B -DskipTests clean package
'''
}
}
}
stage('Test') {
steps {
echo "Testing.."
script {
sh '''
mvn -f ./YouQuiz/pom.xml test
'''
}
}
}
stage('Login') {
steps {
echo "Login..."
sh 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin'
}
}
stage('Deliver') {
steps {
echo "Deliver..."
sh 'docker push ahmedennaime/youquiz:1.0'
}
}
}
}