ci: do not run the pipeline if PR is draft

If the PR is a draft, it's not ready for review and most likely the CI
pipeline should not run as the code might be broken in some places.

Signed-off-by: Sébastien Han <seb@redhat.com>
This commit is contained in:
Sébastien Han committed 2020-06-03 10:19:28 +02:00
1 parent 9911e5ccc9
commit c9d306fe61
1 file changed
+5
Vendored
+5
View File
@@ -20,6 +20,11 @@ pipeline {
script {
pr_number = sh (script: "echo ${env.BRANCH_NAME} | grep -o -E '[0-9]+' ",returnStdout: true)
def json = sh (script: "curl -s https://api.github.com/repos/rook/rook/pulls/${pr_number}", returnStdout: true).trim()
def draft = evaluateJson(json,'${json.draft}')
if (draft.contains("true")) {
echo ("This is a draft PR. Aborting")
env.shouldBuild = "false"
}
def body = evaluateJson(json,'${json.body}')
if (body.contains("[skip ci]")) {
echo ("'[skip ci]' spotted in PR body text. Aborting.")