forked from sdgcpsb/SpringBootRestApp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
105 lines (96 loc) · 2.5 KB
/
Jenkinsfile
File metadata and controls
105 lines (96 loc) · 2.5 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
102
103
104
105
pipeline {
environment {
PROJECT_ID = "sd-devops"
APP_NAME = "sample-java-app"
CLUSTER_NAME = "cluster-1"
CLUSTER_ZONE = "us-central1-a"
CREDENTIALS_ID = "sd-devops"
}
//agent any 2
agent {
kubernetes {
label 'SpringBootRestApp'
defaultContainer 'jnlp'
yaml """
apiVersion: v1
kind: Pod
metadata:
labels:
component: ci
spec:
containers:
- name: gradle
image: gradle:3.5-jdk8-alpine
command:
- cat
tty: true
"""
}
}
stages {
stage('check_gradle_version') {
steps {
container('gradle') {
sh 'gradle -v'
sh 'echo workspace is $WORKSPACE'
sh "ls -la ${pwd()}"
sh 'chmod 777 * '
sh './gradlew compileJava'
}
}
}
stage('Unit Test') {
steps {
container('gradle') {
withMaven(maven: 'MAVEN-3.6.3') {
withSonarQubeEnv(installationName:'Sonarqube') {
echo 'I am executing unit test'
sh "ls -la ${pwd()}"
sh 'mvn -f sample-java-app/pom.xml clean package'
}
}
}
}
}
stage('Code Quality') {
steps {
container('gradle') {
withMaven(maven: 'MAVEN-3.6.3') {
withSonarQubeEnv(installationName:'Sonarqube') {
echo 'I am executing code quality using sonarqube'
sh 'mvn -f sample-java-app/pom.xml sonar:sonar'
}
sleep(60)
timeout(time: 1, unit: 'MINUTES') {
waitForQualityGate abortPipeline: true
}
}
}
}
}
/*stage('Publish Package') {
steps {
container('gradle') {
withMaven(maven: 'MAVEN-3.6.3') {
echo 'I am executing build and push the artifact with unique name showing the branch from which it is generated, to Archiva'
sh 'mvn -X deploy:deploy-file -Dfile=sample-java-app/target/sample-0.0.1-SNAPSHOT.jar -DpomFile=sample-java-app/pom.xml -DrepositoryId=snapshots -Durl=http://35.188.92.10/repository/snapshots/'
}
}
}
}
/* stage('Deploy Dev') {
when { branch 'dev'}
steps {
echo "I am executing Deploy the artifact from Archiva to target dev environment. My artifact has a unique name which is automatically generated and deployed to target dev environment"
echo "Work in progress"
}
}
stage('Smoke Test'){
when { branch 'dev'}
steps {
echo "I am executing Smoke Test on target dev environment post deployment"
echo 'Work in progress'
}
} */
}
}