From 2e3ba9ca13685e8bc927125e47e344c85db75ecb Mon Sep 17 00:00:00 2001 From: Craig Comstock Date: Thu, 21 Aug 2025 11:44:27 -0500 Subject: [PATCH] Fixed Jenkinsfile for non pull request builds Need to conditionally access pullRequest object depending on existence of env.CHANGE_ID as described here: https://plugins.jenkins.io/pipeline-github/ Ticket: ENT-12581 Changelog: none --- Jenkinsfile | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 425332494..afc46c112 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,7 +2,7 @@ pipeline { agent { label 'CONTAINERS' } environment { REPOS = "core enterprise nova masterfiles northerntechhq/nt-docs" - PR_BASE="${pullRequest.base}" + PR_BASE = getPR_BASE() PACKAGE_JOB = "cf-remote" PACKAGE_UPLOAD_DIRECTORY = "n/a" PACKAGE_BUILD = "n/a" @@ -37,8 +37,12 @@ pipeline { } stage('Checkout repositories'){ steps { - sh "echo \"${pullRequest.title}\" > pull-request-title" - sh "echo \"${pullRequest.body}\" > pull-request-body" + script { + if (env.CHANGE_ID) { + sh "echo \"${pullRequest.title}\" > pull-request-title" + sh "echo \"${pullRequest.body}\" > pull-request-body" + } + } sh "curl -O https://raw.githubusercontent.com/cfengine/buildscripts/refs/heads/master/ci/create-revisions-file.sh" sh "chmod u+x ./create-revisions-file.sh" sh "./create-revisions-file.sh" @@ -122,3 +126,10 @@ mv upload/* output } // stage('Publish to buildcache') } // stages } +def getPR_BASE() { + if (env.CHANGE_ID) { + return "${pullRequest.base}" + } else { + return "" + } +}