diff --git a/Jenkinsfile b/Jenkinsfile index c838459..0767031 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,11 +1,3 @@ -// 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 { @@ -19,11 +11,24 @@ pipeline { stages { stage('Download source code from Git') { steps { - git( - url: httpUrl, - credentialsId: 'gitlab-jenkins-localhost', - branch: 'test' - ) + script{ + switch(GIT_BRANCH) { + case "vapor/production": + git( + url: 'https://gitlab.com/CIEFWorldwideSdnBhd/vapor-laravel-explore.git', + credentialsId: 'gitlab-jenkins-localhost', + branch: 'vapor/production' + ) + break + case "vapor/staging": + git( + url: 'https://gitlab.com/CIEFWorldwideSdnBhd/vapor-laravel-explore.git', + credentialsId: 'gitlab-jenkins-localhost', + branch: 'vapor/staging' + ) + break + } + } } } @@ -44,7 +49,14 @@ pipeline { script{ String gitCommitMessage = getCommitMessage() println("GIT CommitMessage: " + gitCommitMessage) - sh "vendor/bin/vapor deploy staging --message='${gitCommitMessage}'" + 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 + } } } }