forked from OpenShiftDemos/openshift-tasks
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Jenkinsfile
28 lines (27 loc) · 1.22 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
node('maven') {
// define commands
def mvnCmd = "mvn"
// injection of environment variables is not done so set them here...
def sourceRef = "master"
def sourceUrl = "https://github.com/lbroudoux/openshift-tasks"
def devProject = "ocp-tasks"
def applicationName = "jkf-tasks"
stage 'build'
git branch: sourceRef, url: sourceUrl
sh "${mvnCmd} clean install -DskipTests=true"
stage 'test'
sh "${mvnCmd} test"
stage 'deployInDev'
sh "rm -rf oc-build && mkdir -p oc-build/deployments"
sh "cp target/openshift-tasks.war oc-build/deployments/ROOT.war"
// clean up. keep the image stream
sh "oc project ${devProject}"
sh "oc delete bc,dc,svc,route -l application=${applicationName} -n ${devProject}"
// create build. override the exit code since it complains about existing imagestream
sh "oc new-build --name=${applicationName} --image-stream=jboss-eap70-openshift --binary=true --labels=application=${applicationName} -n ${devProject} || true"
// build image
sh "oc start-build ${applicationName} --from-dir=oc-build --wait=true -n ${devProject}"
// deploy image
sh "oc new-app ${applicationName}:latest -n ${devProject}"
sh "oc expose svc/${applicationName} -n ${devProject}"
}