forked from US-ELRR/elrrexternalservices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
126 lines (114 loc) · 3.57 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
pipeline {
environment {
registryCredential = "mohan.nelakurti"
}
agent any
stages {
stage(‘Build’) {
steps{
script {
sh 'mvn clean install'
}
}
}
stage(‘Load’) {
steps{
script {
app = docker.build("cloud007/simple-spring")
}
}
}
stage(‘Deploy’) {
steps{
script {
docker.withRegistry( "https://registry.hub.docker.com", registryCredential ) {
// dockerImage.push()
app.push("latest")
}
}
}
}
stage('Deploy to Kubernates'){
steps{
sh 'echo "Kubernates deployment" '
sh 'kubectl apply -f sample.yaml'
}
}
}
}
pipeline {
agent any
environment {
// use your actual issuer URL here and NOT the placeholder {yourOktaDomain}
OKTA_OAUTH2_ISSUER = '{yourOktaDomain}/oauth2/default'
OKTA_OAUTH2_CLIENT_ID = credentials('OKTA_OAUTH2_CLIENT_ID')
OKTA_OAUTH2_CLIENT_SECRET = credentials('OKTA_OAUTH2_CLIENT_SECRET')
}
stages {
stage('Build') {
steps {
// Get some code from a GitHub repository
git 'https://github.com/<your-username>/simple-app.git'
// Run Maven on a Unix agent.
sh "./mvnw -Dmaven.test.failure.ignore=true clean package"
// To run Maven on a Windows agent, use
// bat "mvn -Dmaven.test.failure.ignore=true clean package"
}
post {
// If Maven was able to run the tests, even if some of the test
// failed, record the test results and archive the jar file.
success {
junit '**/target/surefire-reports/TEST-*.xml'
archiveArtifacts 'target/*.jar'
}
}
}
}
}
node {
stage 'Clone the project'
git 'https://github.com/US-ELRR/elrrdataservices.git'
dir('spring-jenkins-pipeline') {
stage("Compilation and Analysis") {
parallel 'Compilation': {
sh "./mvnw clean install -DskipTests"
}
}
stage("Tests and Deployment") {
parallel 'Unit tests': {
stage("Runing unit tests") {
try {
sh "./mvnw test -Punit"
} catch(err) {
step([$class: 'JUnitResultArchiver', testResults:
'**/target/surefire-reports/TEST-*UnitTest.xml'])
throw err
}
step([$class: 'JUnitResultArchiver', testResults:
'**/target/surefire-reports/TEST-*UnitTest.xml'])
}
}, 'Integration tests': {
stage("Runing integration tests") {
try {
sh "./mvnw test -Pintegration"
} catch(err) {
step([$class: 'JUnitResultArchiver', testResults:
'**/target/surefire-reports/TEST-'
+ '*IntegrationTest.xml'])
throw err
}
step([$class: 'JUnitResultArchiver', testResults:
'**/target/surefire-reports/TEST-'
+ '*IntegrationTest.xml'])
}
}
stage("Staging") {
sh "pid=\$(lsof -i:8989 -t); kill -TERM \$pid "
+ "|| kill -KILL \$pid"
withEnv(['JENKINS_NODE_COOKIE=dontkill']) {
sh 'nohup ./mvnw spring-boot:run -Dserver.port=8989 &'
}
}
}
}
}