-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample-pipeline
58 lines (57 loc) · 1.34 KB
/
sample-pipeline
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
pipeline {
agent any
tools{
jdk 'jdk17'
maven 'maven'
// tESTING
}
environment{
DOCKER_IMAGE= "nandyuvi/9043:${BUILD_NUMBER}"
}
stages {
stage('GIT Checkout') {
steps {
git 'https://github.com/nandha-coder/secretsanta-nandha.git'
}
}
stage('Code Compile') {
steps {
sh 'echo ${BUILD_NUMBER} > abc.txt && mvn clean compile'
}
}
stage('Unit Test') {
steps {
sh 'mvn test'
}
}
stage('SonarQube Analysis') {
environment {
SONAR_URL = "http://64.227.184.243:9000"
}
steps {
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_AUTH_TOKEN')]) {
sh 'mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}'
}
}
}
stage('Code Build') {
steps {
sh 'mvn clean package'
}
}
stage('Image Build') {
steps {
sh 'docker build -t ${DOCKER_IMAGE} .'
}
}
stage('Image Push') {
steps {
script {
withDockerRegistry(credentialsId: 'docker-username-password', toolName: 'docker') {
sh 'docker push ${DOCKER_IMAGE}'
}
}
}
}
}
}