-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
Jenkins 2.235.5
BlueOcean 1.23.2
Here's a pipeline I'm comfortable sharing. It cleans up the old folders in Jenkins workspace across all online nodes.
When the number of nodes passes 15-20, the BlueOcean view gets stuck. Fans kick in. This quickly gets Safari/Chrome/Firefox to get stuck in our environment.
The above is correct even for the jobs that have completely finished quite a while ago.
def builders = [:].asSynchronized() node('master') { stage('Pre-flight') { String[] node_names = [] for (Node node in Hudson.instance.nodes) { if (node != null && node.toComputer() != null && node.toComputer().online) { node_names += node.getNodeName() } node = null } for (node_name in node_names) { def final_node_name = node_name builders[final_node_name] = { node(final_node_name) { timeout(time:5, unit: "MINUTES") { def usage = '' usage = sh(script: "df -h / | tail -n 1 | awk '{print \$5}'", returnStdout: true).trim() println "usage before: ${usage}" sh """#!/bin/bash -x touch ${WORKSPACE}/.dont_remove_workspace sudo find ${WORKSPACE}/.. -mindepth 1 -maxdepth 1 -type d -mmin +180 -print -exec sudo rm -rf {} \\; rm -f ${WORKSPACE}/.dont_remove_workspace """ usage = sh(script: "df -h / | tail -n 1 | awk '{print \$5}'", returnStdout: true).trim() println "usage after: ${usage}" } } } } } } pipeline { agent { node { label 'master'} } triggers { cron('H * * * *')} stages{ stage ('Do the cleanup') { steps { script { if (builders == [:]) { println "No nodes found" currentBuild.result = 'SUCCESS' return } parallel builders } } } } }
Related: JENKINS-62449