From fe8b166d8999fefe9fd3f1cc7568f209fefe2ed4 Mon Sep 17 00:00:00 2001 From: Mike Del Tito Date: Mon, 26 Oct 2020 12:39:15 -0400 Subject: [PATCH] fix: add PR source validation to Jenkinsfile Semver: patch Ref: LOG-7713 --- Jenkinsfile | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e919261..48ff14f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,17 +1,29 @@ library 'magic-butler-catalogue' -def projectName = "logdna-winston" -def repo = "logdna/${projectName}" +def PROJECT_NAME = "logdna-winston" +def REPO = "logdna/${PROJECT_NAME}" +def TRIGGER_PATTERN = ".*@logdnabot.*" pipeline { agent none - options { - timestamps() - ansiColor 'xterm' + triggers { + issueCommentTrigger(TRIGGER_PATTERN) } stages { + stage('Validate PR Source') { + when { + expression { env.CHANGE_FORK } + not { + triggeredBy 'issueCommentCause' + } + } + steps { + error("A maintainer needs to approve this PR for CI by commenting") + } + } + stage('Test Suite') { matrix { axes { @@ -107,7 +119,8 @@ pipeline { versioner( token: "${GITHUB_PACKAGES_TOKEN}" , dry: true - , repo: repo + , repo: REPO + , branch: "master" ) } } @@ -140,8 +153,9 @@ pipeline { versioner( token: "${GITHUB_PACKAGES_TOKEN}" , dry: false - , repo: repo + , repo: REPO , NPM_PUBLISH_TOKEN: "${NPM_PUBLISH_TOKEN}" + , branch: "master" ) } }