From 6cf2570a9f26e7ce049e096f141f62a8498d300e Mon Sep 17 00:00:00 2001 From: Jaroslava Fiedlerova Date: Sun, 8 Mar 2026 20:47:17 +0100 Subject: [PATCH] Jenkinsfile-GitLab-Container: declare local vars in slave job triggers Declare `localStatus` and `localResult` as local variables in `triggerSlaveJob` and `triggerCN5GSlaveJob` functions by adding `def`. This prevents unintended use of global variables in pipeline and avoids potential variable leakage or conflicts between stages. Follows the Jenkins recommendation: Did you forget the `def` keyword? WorkflowScript seems to be setting a field named localStatus (to a value of type RunWrapper) which could lead to memory leaks or other issues. Did you forget the `def` keyword? WorkflowScript seems to be setting a field named localResult (to a value of type String) which could lead to memory leaks or other issues. --- ci-scripts/Jenkinsfile-GitLab-Container | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci-scripts/Jenkinsfile-GitLab-Container b/ci-scripts/Jenkinsfile-GitLab-Container index 7ba01cbf00..e60fb9cbf1 100644 --- a/ci-scripts/Jenkinsfile-GitLab-Container +++ b/ci-scripts/Jenkinsfile-GitLab-Container @@ -864,7 +864,7 @@ def triggerSlaveJob (jobName, gitlabStatusName) { // The slave job is triggered with the propagate false so the following commands are executed // Its status is now PASS/SUCCESS from a stage pipeline point of view // localStatus variable MUST be analyzed to properly assess the status - localStatus = build job: jobName, + def localStatus = build job: jobName, parameters: [ string(name: 'eNB_Repository', value: String.valueOf(GIT_URL)), string(name: 'eNB_Branch', value: String.valueOf(env.gitlabSourceBranch)), @@ -873,7 +873,7 @@ def triggerSlaveJob (jobName, gitlabStatusName) { booleanParam(name: 'eNB_mergeRequest', value: "MERGE".equals(env.gitlabActionType)), string(name: 'eNB_TargetBranch', value: String.valueOf(env.gitlabTargetBranch)) ], propagate: false - localResult = localStatus.getResult() + def localResult = localStatus.getResult() echo "${jobName} Slave Job status is ${localResult}" gitlabCommitStatus(name: gitlabStatusName) { if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) { @@ -899,11 +899,11 @@ def triggerCN5GSlaveJob (jobName, gitlabStatusName) { // The slave job is triggered with the propagate false so the following commands are executed // Its status is now PASS/SUCCESS from a stage pipeline point of view // localStatus variable MUST be analyzed to properly assess the status - localStatus = build job: jobName, + def localStatus = build job: jobName, parameters: [ string(name: 'FULL_RAN_TAG', value: String.valueOf(fullRanTag)) ], propagate: false - localResult = localStatus.getResult() + def localResult = localStatus.getResult() echo "${jobName} Slave Job status is ${localResult}" gitlabCommitStatus(name: gitlabStatusName) { if (localStatus.resultIsBetterOrEqualTo('SUCCESS')) {