-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
78 lines (76 loc) · 2.35 KB
/
Jenkinsfile
File metadata and controls
78 lines (76 loc) · 2.35 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
pipeline {
agent any
environment {
DEPLOY_CREDS = credentials('deploy-anypoint-app')
WORKER = "MICRO"
MULE_KEY = "poc"
}
stages {
stage('Build') {
steps {
configFileProvider([configFile(fileId: "MVN_GLBL_SETT_ID", variable: 'MAVEN_SETTINGS_XML')]) {
bat 'mvn -s "%MAVEN_SETTINGS_XML%" clean -DskipTests package'
}
}
}
stage('Unit Test') {
steps {
configFileProvider([configFile(fileId: "MVN_GLBL_SETT_ID", variable: 'MAVEN_SETTINGS_XML')]) {
bat 'mvn -s "%MAVEN_SETTINGS_XML%" clean test'
}
}
}
stage('Deploy Development') {
when {
branch 'develop' //only run these steps on the develop branch
}
environment {
ENVIRONMENT_CREDS = credentials('anypoint-sandbox-cred')
ENVIRONMENT = 'Sandbox'
APP_NAME = 'cicd-poc-uky-api'
}
steps {
configFileProvider([configFile(fileId: "MVN_GLBL_SETT_ID", variable: 'MAVEN_SETTINGS_XML')]) {
bat 'mvn -s "%MAVEN_SETTINGS_XML%" -DskipTests clean deploy -DmuleDeploy -DgrantType="client_credentials" -DclientId="%DEPLOY_CREDS_USR%" -DclientSecret="%DEPLOY_CREDS_PSW%" -Dcloudhub.application.name="%APP_NAME%" -Denvironment="%ENVIRONMENT%" -DworkerType="%WORKER%" -Danypoint.platform.client_id="%ENVIRONMENT_CREDS_USR%" -Danypoint.platform.client_secret="%ENVIRONMENT_CREDS_PSW%" -Dmule.key="%MULE_KEY%"'
}
echo "Deployed to Development"
}
}
stage('Deploy UAT/Staging') {
when {
branch 'staging' //only run these steps on the staging branch
}
environment {
ENVIRONMENT_CREDS = credentials('anpoint-uat-credentials')
ENVIRONMENT = 'UAT'
APP_NAME = 'cicd-poc-uat-api'
}
steps {
echo "Deployed to UAT"
}
}
stage('Publish Artifact') {
when {
branch 'develop' //only run these steps on the main branch
}
steps{
configFileProvider([configFile(fileId: "MVN_GLBL_SETT_ID", variable: 'MAVEN_SETTINGS_XML')]) {
bat 'mvn -s "%MAVEN_SETTINGS_XML%" -DskipTests clean deploy'
}
}
}
stage('Deploy Prod') {
when {
branch 'main' //only run these steps on the main branch
}
environment {
ENVIRONMENT_CREDS = credentials('anypoint-sandbox-cred')
ENVIRONMENT = 'Production'
APP_NAME = 'cicd-poc-api'
}
steps {
echo "Deployed to Prod"
}
}
}
}