mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
80 lines
1.9 KiB
Groovy
80 lines
1.9 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 {
|
|
git(
|
|
url: httpUrl,
|
|
credentialsId: 'gitlab-jenkins-localhost',
|
|
branch: 'dillon/34-jenkins-vapor'
|
|
)
|
|
}
|
|
}
|
|
|
|
stage('Get Last Commit Details') {
|
|
steps {
|
|
script{
|
|
String gitCommitMessage = getCommitMessage()
|
|
println("GIT CommitMessage: " + gitCommitMessage)
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Get Commit Message for Deployment') {
|
|
steps {
|
|
script {
|
|
sh 'echo $PATH'
|
|
env.GIT_COMMIT_MSG = sh (script: '/usr/bin/git log -1 --pretty=%B ${GIT_COMMIT}', returnStdout: true).trim()
|
|
}
|
|
}
|
|
}
|
|
|
|
stage('Install') {
|
|
steps {
|
|
sh 'composer update'
|
|
}
|
|
}
|
|
|
|
stage('Tests') {
|
|
steps {
|
|
sh 'vendor/bin/phpunit tests/Unit'
|
|
}
|
|
}
|
|
|
|
stage('Deploy') {
|
|
steps {
|
|
sh 'vendor/bin/vapor deploy staging --message="Commit: ${GIT_COMMIT}"'
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
@NonCPS
|
|
String getCommitMessage(){
|
|
commitMessage = " "
|
|
for ( changeLogSet in currentBuild.changeSets){
|
|
for (entry in changeLogSet.getItems()){
|
|
commitMessage = entry.msg
|
|
}
|
|
}
|
|
return commitMessage
|
|
}
|