Skip to content

Commit

Permalink
Globalize bazel remote activation
Browse files Browse the repository at this point in the history
Change-Id: I9541758a28510660e0cca1387828d2722c67e96e
  • Loading branch information
TimotheusBachinger committed Feb 13, 2025
1 parent f6dd239 commit 63ed456
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 20 deletions.
8 changes: 3 additions & 5 deletions buildscripts/scripts/build-cmk-distro-package.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,9 @@ def main() {
passwordVariable: 'NEXUS_PASSWORD',
usernameVariable: 'NEXUS_USERNAME'),
]) {
withCredentialFileAtLocation(credentialsId:"remote.bazelrc", location:"${checkout_dir}/remote.bazelrc") {
/// Don't use withEnv, see
/// https://issues.jenkins.io/browse/JENKINS-43632
sh("${omd_env_vars.join(' ')} make -C omd ${package_type}");
}
/// Don't use withEnv, see
/// https://issues.jenkins.io/browse/JENKINS-43632
sh("${omd_env_vars.join(' ')} make -C omd ${package_type}");
}

package_name = cmd_output("ls check-mk-${edition}-${cmk_version}*.${package_type}");
Expand Down
4 changes: 3 additions & 1 deletion buildscripts/scripts/jenkins_job_entry.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def main(job_definition_file) {

def notify = load("${checkout_dir}/buildscripts/scripts/utils/notify.groovy");
try {
load("${checkout_dir}/${job_definition_file}").main();
withCredentialFileAtLocation(credentialsId:"remote.bazelrc", location:"${checkout_dir}/remote.bazelrc") {
load("${checkout_dir}/${job_definition_file}").main();
}
} catch(Exception exc) {
dir("${checkout_dir}") {
notify.notify_error(exc);
Expand Down
6 changes: 2 additions & 4 deletions buildscripts/scripts/test-python3-unit-all.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ def main() {
dir("${checkout_dir}") {
withCredentials([
]) {
withCredentialFileAtLocation(credentialsId:"remote.bazelrc", location:"${checkout_dir}/remote.bazelrc") {
lock(label: "bzl_lock_${env.NODE_NAME.split('\\.')[0].split('-')[-1]}", quantity: 1, resource: null) {
sh("make -C tests test-unit-all");
}
lock(label: "bzl_lock_${env.NODE_NAME.split('\\.')[0].split('-')[-1]}", quantity: 1, resource: null) {
sh("make -C tests test-unit-all");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions buildscripts/scripts/utils/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ withCredentialFileAtLocation = {Map args, Closure body ->
body.delegate = [:];
try {
withCredentials([file(credentialsId: args.credentialsId, variable: "SECRET_LOCATION")]) {
sh("cp ${SECRET_LOCATION} ${args.location}");
cmd_output("cp ${SECRET_LOCATION} ${args.location}");
body();
}
return true;
} finally {
sh("rm -f ${args.location}");
cmd_output("rm -f ${args.location}");
}
};
3 changes: 1 addition & 2 deletions buildscripts/scripts/utils/gerrit_stages.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def create_stage(Map args, time_stage_started) {

withCredentials(args.SEC_VAR_LIST.collect{string(credentialsId: it, variable: it)}) {
withEnv(args.ENV_VAR_LIST) {
withCredentialFileAtLocation(credentialsId:"remote.bazelrc", location:"${checkout_dir}/remote.bazelrc") {
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
dir(args.DIR) {
// be very carefull here. Setting quantity to 0 or null, takes all available resources
Expand Down Expand Up @@ -72,7 +71,7 @@ def create_stage(Map args, time_stage_started) {

/// make the stage fail if the command returned nonzero
sh("exit ${cmd_status}");
}}
}
}
}
return [cmd_status == 0, issues];
Expand Down
10 changes: 4 additions & 6 deletions buildscripts/scripts/utils/test_helper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,10 @@ def execute_test(Map config = [:]) {
if (defaultDict.output_file) {
cmd += " 2>&1 | tee ${defaultDict.output_file}";
}
withCredentialFileAtLocation(credentialsId:"remote.bazelrc", location:"${checkout_dir}/remote.bazelrc") {
sh("""
set -o pipefail
${cmd}
""");
}
sh("""
set -o pipefail
${cmd}
""");
}
}
}
Expand Down

0 comments on commit 63ed456

Please sign in to comment.