Skip to content

Commit 27486aa

Browse files
gursewak1997dustymabe
authored andcommitted
release: Fix GC conditional check
Refactor load_gc function to streamline file path handling and improve error handling, while updating the GC job trigger to check gc_policy_data for better clarity and robustness.
1 parent ad28b4d commit 27486aa

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

jobs/release.Jenkinsfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ node {
44
pipeutils = load("utils.groovy")
55
pipecfg = pipeutils.load_pipecfg()
66
libcloud = load("libcloud.groovy")
7+
gc_policy_data = pipeutils.load_gc()
78
}
89

910
def brew_principal = pipecfg.brew?.principal
@@ -343,7 +344,7 @@ lock(resource: "release-${params.STREAM}", extra: locks) {
343344
}
344345
}
345346
// Trigger the GC job only if `gc-policy.yaml` exists, which currently applies only to FCOS.
346-
if (pipeutils.load_gc()) {
347+
if (gc_policy_data) {
347348
stage('Fork Garbage Collection') {
348349
build job: 'garbage-collection', wait: false, parameters: [
349350
string(name: 'STREAM', value: params.STREAM),

utils.groovy

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ def load_gc() {
9898
def jenkinscfg = load_jenkins_config()
9999
def url = jenkinscfg['pipecfg-url']
100100
def gc_policy_data
101+
def filePath = (url == 'in-tree') ? 'gc-policy.yaml' : 'pipecfg/gc-policy.yaml'
101102

102-
if (url == 'in-tree') {
103-
gc_policy_data = readYaml(file: "gc-policy.yaml")
103+
if (fileExists(filePath)) {
104+
gc_policy_data = readYaml(file: filePath)
104105
} else {
105-
// assume the user called `load_pipecfg()` in this workdir; if not, let error out
106-
gc_policy_data = readYaml(file: "pipecfg/gc-policy.yaml")
106+
echo "GC policy file '${filePath}' not found. Skipping load."
107+
return null
107108
}
108109

109110
return gc_policy_data

0 commit comments

Comments
 (0)