From 84e238ed06e1369912cf9a4dc6f154071ee99cf7 Mon Sep 17 00:00:00 2001 From: Christophe Demarey Date: Tue, 12 Apr 2022 14:16:51 +0200 Subject: [PATCH] upload only if in dev branch --- Jenkinsfile | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f01b97b1..7b01aa10 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,8 +87,8 @@ def buildArchitecture(architecture, pharoVersion) { } } - //Do not deploy if in PR - if (isPullRequest()){ + // Do not deploy if not in dev branch + if ( shouldNotUpload() ){ return; } node('linux') { @@ -124,9 +124,7 @@ def notifyBuild() { } def cleanUploadFolderIfNeeded(launcherVersion) { - if (isPullRequest()) { - //Only upload files if not in a PR (i.e., CHANGE_ID not empty) - echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + if (shouldNotUpload()) { return; } @@ -160,9 +158,7 @@ def finalizeUpload(launcherVersion) { } def upload(file, launcherVersion) { - if (isPullRequest()) { - //Only upload files if not in a PR (i.e., CHANGE_ID not empty) - echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + if (shouldNotUpload()) { return; } @@ -186,6 +182,26 @@ def fileNameArchSuffix(architecture) { return (architecture == '64') ? 'x64' : architecture } +def shouldNotUpload() { + if (isPullRequest()) { + //Only upload files if not in a PR (i.e., CHANGE_ID not empty) + echo "[DO NO UPLOAD] In PR " + (env.CHANGE_ID?.trim()) + return true + } + + if (isNotDevBranch()) { + echo "[DO NO UPLOAD] In branch " + (env.BRANCH_NAME?.trim()) + return true + } + + // Do upload + return false +} + +def isNotDevBranch() { + return env.BRANCH_NAME != "dev" +} + def isPullRequest() { return env.CHANGE_ID != null }