-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile.examples
37 lines (36 loc) · 1.34 KB
/
Jenkinsfile.examples
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
node {
def SOURCEDIR = pwd()
def TEST_CONTAINER = 'examples/ruby-test'
def DOCKERFILE_DIR = './examples/docker'
try {
stage("Clean up") {
step([$class: 'WsCleanup'])
}
stage("Checkout Code") {
checkout scm
}
stage("Build Dockerfile") {
dir ("${DOCKERFILE_DIR}") {
sh "docker build --no-cache -t ${TEST_CONTAINER} ."
}
}
stage("Run Examples") {
echo "${env.ALT_URL}"
def useUrl = ("${env.ALT_URL}" == "null") ? "${env.BINDING_TEST_URL}" : "${env.ALT_URL}"
withEnv(["API_KEY=${env.ROSETTE_API_KEY}", "ALT_URL=${useUrl}"]) { sh "docker run --rm -e API_KEY=${API_KEY} -e ALT_URL=${ALT_URL} -v ${SOURCEDIR}:/source ${TEST_CONTAINER}"
}
}
postToTeams(true)
} catch (e) {
currentBuild.result = "FAILED"
postToTeams(false)
throw e
}
}
def postToTeams(boolean success) {
def webhookUrl = "${env.TEAMS_PNC_JENKINS_WEBHOOK_URL}"
def color = success ? "#00FF00" : "#FF0000"
def status = success ? "SUCCESSFUL" : "FAILED"
def message = "*" + status + ":* '${env.JOB_NAME}' - [${env.BUILD_NUMBER}] - ${env.BUILD_URL}"
office365ConnectorSend(webhookUrl: webhookUrl, color: color, message: message, status: status)
}