-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathJenkinsfile
executable file
·97 lines (91 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
pipeline {
parameters {
choice(name: 'env', choices: ['test', 'prod'], description: 'Pick environment')
}
agent {
dockerfile true
}
environment {
APIGEE_CREDS = credentials('apigee')
APIGEE_DEVPORTAL_CREDS = credentials('apigee-devportal')
HOME = '.'
}
stages {
stage('Clean') {
steps {
script{
if (env.GIT_BRANCH == "master") {
env.APIGEE_PREFIX = ""
env.APIGEE_PROFILE = "test"
} else if (env.GIT_BRANCH == "prod") {
env.APIGEE_PREFIX = ""
env.APIGEE_PROFILE = "prod"
} else { //feature branches
env.APIGEE_PREFIX = "jenkins"
env.APIGEE_PROFILE = "test"
}
}
sh "mvn clean"
}
}
stage('Static Code Analysis, Unit Test and Coverage') {
steps {
sh "mvn -ntp test -P${env.APIGEE_PROFILE} -Ddeployment.suffix=${env.APIGEE_PREFIX} -Dcommit=${env.GIT_COMMIT} -Dbranch=${env.GIT_BRANCH} -Duser.name=jenkins"
}
}
stage('Configurations') {
steps {
sh "mvn -ntp apigee-config:keyvaluemaps apigee-config:targetservers apigee-config:caches -P${env.APIGEE_PROFILE} -Dusername=${APIGEE_CREDS_USR} -Dpassword=${APIGEE_CREDS_PSW} -Dapigee.config.options=update -Dapigee.config.dir=${WORKSPACE}/resources/edge"
}
}
stage('Package proxy bundle') {
steps {
sh "mvn -ntp apigee-enterprise:configure -P${env.APIGEE_PROFILE} -Ddeployment.suffix=${env.APIGEE_PREFIX}"
}
}
stage('Deploy proxy bundle') {
steps {
sh "mvn -ntp apigee-enterprise:deploy -P${env.APIGEE_PROFILE} -Ddeployment.suffix=${env.APIGEE_PREFIX} -Dusername=${APIGEE_CREDS_USR} -Dpassword=${APIGEE_CREDS_PSW}"
}
}
stage('Functional Test') {
steps {
sh "node ./node_modules/cucumber/bin/cucumber.js target/test/integration/features --format json:target/reports.json"
}
}
}
post {
always {
publishHTML(target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: "coverage/lcov-report",
reportFiles: 'index.html',
reportName: 'HTML Report'
]
)
step([
$class: 'CucumberReportPublisher',
fileExcludePattern: '',
fileIncludePattern: "**/reports.json",
ignoreFailedTests: false,
jenkinsBasePath: '',
jsonReportDirectory: "target",
missingFails: false,
parallelTesting: false,
pendingFails: false,
skippedFails: false,
undefinedFails: false
])
}
/*success {
script{
if (env.GIT_BRANCH == "master") {
//dev portal
sh "mvn -ntp install -Pdevportal -Dportal.username=${APIGEE_DEVPORTAL_CREDS_USR} -Dportal.password=${APIGEE_DEVPORTAL_CREDS_PSW} -Dapigee.smartdocs.config.options=update -f pom-devportal.xml"
}
}
}*/
}
}