-
Notifications
You must be signed in to change notification settings - Fork 12
/
Jenkinsfile
66 lines (59 loc) · 1.98 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
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: "100"))
}
agent any
stages {
stage('composer install') {
steps {
sh 'composer install'
}
}
stage('phpunit tests') {
steps {
script {
sh 'mkdir logs'
sh 'php vendor/bin/phpunit --log-junit logs/phpunit_results.xml --configuration test/phpunit.xml --teamcity '
}
}
}
}
post {
always {
echo 'One way or another, I have finished'
archiveArtifacts allowEmptyArchive:true, artifacts: 'logs/*'
junit testResults:'logs/*.xml', allowEmptyResults:false
}
success {
echo 'I succeeeded!'
}
unstable {
script {
echo 'I am unstable :/'
rocketSend(channel: "#ci-commit", color: 'yellow', emoji: ':woozy_face:', rawMessage: true, message: "Oh no! ${JOB_NAME_UNESCAPED} Build is unstable! (${currentBuild.result}), Author: ${GIT_AUTHOR}, sha1: ${SHORT_SHA1}), (${env.BUILD_URL})")
}
}
failure {
script {
echo 'I failed :('
rocketSend(channel: "#ci-commit", color: 'red', emoji: ':sob:', rawMessage: true, message: "Oh no! ${JOB_NAME_UNESCAPED} Build failed! (${currentBuild.result}), Author: ${GIT_AUTHOR}, sha1: ${SHORT_SHA1}), (${env.BUILD_URL})")
}
}
fixed {
script {
rocketSend(channel: "#ci-commit", color: 'green', emoji: ':love_you_gesture:', rawMessage: true, message: "Yes! ${JOB_NAME_UNESCAPED} Build repaired! (${currentBuild.result}), Author: ${GIT_AUTHOR}, sha1: ${SHORT_SHA1}), (${env.BUILD_URL})")
}
}
}
environment {
JOB_NAME_UNESCAPED = env.JOB_NAME.replaceAll("%2F", "/")
GIT_AUTHOR = sh(
returnStdout: true,
script: 'git log -n 1|grep Author|sed -e "s/.*Author: //g"|sed -e "s/<.*//g"'
)
SHORT_SHA1 = sh(
returnStdout: true,
script: "echo ${GIT_COMMIT}|cut -c1-8"
)
}
}