-
Notifications
You must be signed in to change notification settings - Fork 65
/
jenkinsfile
95 lines (84 loc) · 1.7 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
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
pipeline {
agent none
stages
{
agent { label 'deploy' }
stage('Checkout')
{
steps {
git branch: 'master', url: 'https://github.com/scmlearningcentre/seminar.git'
}
}
stage('Build War')
{
agent { label 'deploy' }
steps {
sh "mvn clean package"
}
}
stage('Upload Artifactory')
{
agent { label 'deploy' }
steps {
script {
/* Define the Artifactory Server details */
def server = Artifactory.server 'myartifactory'
def uploadSpec = """{
"files": [{
"pattern": "target/samplewar.war",
"target": "demo"
}]
}"""
/* Upload the war to Artifactory repo */
server.upload(uploadSpec)
}
}
}
stage('Build Image')
{
agent { label 'deploy' }
steps{
script {
docker.withRegistry( 'https://registry.hub.docker.com', 'dockerhub' ) {
/* Build Docker Image locally */
myImage = docker.build("adamtravis/testimg")
/* Push the container to the Registry */
myImage.push()
}
}
}
}
stage('Run Sanity')
{
agent { label 'deploy' }
steps {
sh "./runsanity.sh testimg"
}
}
stage('SonarQube Analysis')
{
agent { label 'deploy' }
steps{
withSonarQubeEnv('mysonarqube') {
sh 'mvn sonar:sonar'
}
}
}
stage('Deployment K8S')
{
agent { label 'deploy' }
steps {
sh "kubectl get nodes"
}
}
}
post
{
success {
echo 'JENKINS PIPELINE SUCCESSFUL'
}
failure {
mail body: 'Pipeline Details', subject: 'The Pipeline failed', to: '[email protected]'
}
}
}