diff --git a/Jenkinsfile b/Jenkinsfile index bde9ab1..d36c5bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -119,6 +119,45 @@ pipeline { } } + stage('Pull Request') { + when { + not { + environment name: 'CHANGE_ID', value: '' + } + environment name: 'CHANGE_TARGET', value: 'master' + } + steps { + node(label: 'docker') { + script { + if ( env.CHANGE_BRANCH != "develop" && !( env.CHANGE_BRANCH.startsWith("hotfix")) ) { + error "Pipeline aborted due to PR not made from develop or hotfix branch" + } + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN')]) { + sh '''docker pull eeacms/gitflow''' + sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-pr" -e GIT_CHANGE_TARGET="$CHANGE_TARGET" -e GIT_CHANGE_BRANCH="$CHANGE_BRANCH" -e GIT_CHANGE_AUTHOR="$CHANGE_AUTHOR" -e GIT_CHANGE_TITLE="$CHANGE_TITLE" -e GIT_TOKEN="$GITHUB_TOKEN" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" -e GIT_ORG="$GIT_ORG" -e GIT_NAME="$GIT_NAME" eeacms/gitflow''' + } + } + } + } + } + + stage('Release') { + when { + allOf { + environment name: 'CHANGE_ID', value: '' + branch 'master' + } + } + steps { + node(label: 'docker') { + withCredentials([string(credentialsId: 'eea-jenkins-token', variable: 'GITHUB_TOKEN'),string(credentialsId: 'eea-jenkins-npm-token', variable: 'NPM_TOKEN')]) { + sh '''docker pull eeacms/gitflow''' + sh '''docker run -i --rm --name="$BUILD_TAG-gitflow-master" -e GIT_BRANCH="$BRANCH_NAME" -e GIT_NAME="$GIT_NAME" -e GIT_TOKEN="$GITHUB_TOKEN" -e NPM_TOKEN="$NPM_TOKEN" eeacms/gitflow''' + } + } + } + } + } post {