-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
53 lines (46 loc) · 1.42 KB
/
Jenkinsfile
File metadata and controls
53 lines (46 loc) · 1.42 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
pipeline {
agent any
tools {
maven 'maven'
}
parameters {
choice(name: 'DEPLOY_ENV', choices: ['dev', 'staging', 'production'], description: 'Choose the environment to deploy to')
}
environment {
APP_ENV = "${params.DEPLOY_ENV}"
}
stages {
stage('Build') {
steps {
echo "Building the Spring PetClinic application for ${APP_ENV} environment..."
sh 'mvn clean install'
}
}
stage('Test') {
steps {
echo "Running tests for ${APP_ENV} environment..."
sh 'mvn test'
}
}
stage('Deploy') {
when {
anyOf {
expression { params.DEPLOY_ENV == 'dev' }
expression { params.DEPLOY_ENV == 'staging' }
expression { params.DEPLOY_ENV == 'production' }
}
}
steps {
// Make sure to use the correct deploy step if you're using a plugin
deploy adapters: [tomcat7(credentialsId: 'tomcat-username-password', path: '', url: 'http://3.87.202.232:8080/')],
contextPath: '', war: '**/*.war'
}
}
}
post {
always {
echo "Cleaning up..."
// Add cleanup steps if needed
}
}
}