Files
exchange-2.0/Jenkinsfile
T

83 lines
2.5 KiB
Groovy

// Webhook + Gitlab git pull + Vapor
// def payload = readJSON text: "${payload}"
// String userName = payload.user_name
// String userEmail = payload.user_email
// String httpUrl = payload.project.http_url
pipeline {
agent {
docker {
image 'dillonngo/docker-based-image:poc'
args "--group-add 992 -v /var/run/docker.sock:/var/run/docker.sock"
}
}
environment {
HOME = '.'
}
stages {
stage('Download source code from Git') {
steps {
script{
switch(GIT_BRANCH) {
case "vapor/production":
case "vapor/staging":
case "origin/dillon/34-jenkins-vapor":
git(
url: 'https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git',
credentialsId: 'gitlab-jenkins-localhost',
branch: GIT_BRANCH
)
break
}
}
}
}
stage('Install') {
steps {
sh 'composer update'
}
}
stage('Tests') {
steps {
sh 'vendor/bin/phpunit tests/Unit'
}
}
stage('Deploy') {
steps {
script{
String gitCommitMessage = getCommitMessage()
println("GIT CommitMessage: " + gitCommitMessage)
println("GIT GIT_BRANCH: " + GIT_BRANCH)
switch(GIT_BRANCH) {
case "vapor/production":
sh "vendor/bin/vapor deploy production --message='${gitCommitMessage}'"
break
case "vapor/staging":
sh "vendor/bin/vapor deploy staging --message='${gitCommitMessage}'"
break
case "origin/dillon/34-jenkins-vapor":
sh "vendor/bin/vapor deploy staging --message='${gitCommitMessage}'"
break
}
}
}
}
}
}
@NonCPS
String getCommitMessage(){
commitMessage = " "
for ( changeLogSet in currentBuild.changeSets){
for (entry in changeLogSet.getItems()){
commitMessage = entry.msg
}
}
return commitMessage
}