Skip to content

Commit dc7f419

Browse files
Sbachmei/bugfix/fix timeout env error and cleanup depths (#83)
* hard-code timeout instead of env var * fix cleanup depth for shared dir
1 parent 94cfe61 commit dc7f419

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

CHANGELOG.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
**2.2.4 - 02/10/26**
22

3-
- Fix doc only / changelog only skipping behavior
3+
- Bugfix: fix timeout env variable in jenkinsfile
4+
- Bugfix: fix the cleanup depth for the shared directory
5+
- Bugfix: fix doc-only / changelog-only skipping behavior
46

57
**2.2.3 - 02/09/26**
68

Jenkinsfile.cleanup

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ pipeline {
55
DIRS_TO_CLEAN_PER_NODE = '/tmp,/opt/jenkins/workspace'
66
DIRS_TO_CLEAN_SHARED = '/mnt/team/simulation_science/priv/engineering/jenkins/envs'
77
DAYS_OLD = '3'
8-
TIMEOUT = '120' // minutes
98
}
109

1110
options {
1211
skipDefaultCheckout()
13-
timeout(time: env.TIMEOUT.toInteger(), unit: 'MINUTES')
12+
timeout(time: 120, unit: 'MINUTES')
1413
timestamps()
1514
buildDiscarder(logRotator(numToKeepStr: '30'))
1615
}
@@ -115,7 +114,7 @@ pipeline {
115114
def channelName = "simsci-ci-status"
116115
def slackID = "channel"
117116
def slackMessage = """
118-
Cleanup was aborted (likely due to the ${env.TIMEOUT}-minute timeout).
117+
Cleanup was aborted (likely due to timeout).
119118

120119
Job: *${env.JOB_NAME}*
121120
Build number: #${env.BUILD_NUMBER}
@@ -158,6 +157,12 @@ def cleanDirs(cleanupType) {
158157

159158
// Determine which directories to clean based on cleanup type
160159
def dirsToClean = cleanupType == "shared" ? env.DIRS_TO_CLEAN_SHARED : env.DIRS_TO_CLEAN_PER_NODE
160+
161+
// Set depth based on cleanup type.
162+
// Directories are created directly at the DIRS_TO_CLEAN_PER_NODE level, but
163+
// the builds on the DIRS_TO_CLEAN_SHARED are created in subdirectories e.g.
164+
// /mnt/team/simulation_science/priv/engineering/jenkins/envs/{stash,git}_repos/vivarium/<build-to-delete>
165+
def depth = cleanupType == "shared" ? "3" : "1"
161166

162167
// Split the directories and loop through them
163168
def dirList = dirsToClean.split(',')
@@ -194,17 +199,17 @@ def cleanDirs(cleanupType) {
194199

195200
# Remove directories (excluding this build's 'cleanup*' dirs)
196201
echo "Listing (non-cleanup) directories in ${dir} older than ${env.DAYS_OLD} days:"
197-
find "${dir}" -mindepth 1 -maxdepth 1 -mtime +${env.DAYS_OLD} -type d ! -name 'cleanup*'
202+
find "${dir}" -mindepth ${depth} -maxdepth ${depth} -mtime +${env.DAYS_OLD} -type d ! -name 'cleanup*'
198203

199204
echo "Deleting (non-cleanup) directories:"
200-
find "${dir}" -mindepth 1 -maxdepth 1 -mtime +${env.DAYS_OLD} -type d ! -name 'cleanup*' -exec rm -rf {} + || echo "Some directories could not be deleted due to permissions"
205+
find "${dir}" -mindepth ${depth} -maxdepth ${depth} -mtime +${env.DAYS_OLD} -type d ! -name 'cleanup*' -exec rm -rf {} + || echo "Some directories could not be deleted due to permissions"
201206

202207
# Remove files
203208
echo "Listing files in ${dir} older than ${env.DAYS_OLD} days:"
204-
find "${dir}" -mindepth 1 -maxdepth 1 -mtime +${env.DAYS_OLD} -type f
209+
find "${dir}" -mindepth ${depth} -maxdepth ${depth} -mtime +${env.DAYS_OLD} -type f
205210

206211
echo "Deleting files:"
207-
find "${dir}" -mindepth 1 -maxdepth 1 -mtime +${env.DAYS_OLD} -type f -exec rm -f {} + || echo "Some files could not be deleted due to permissions"
212+
find "${dir}" -mindepth ${depth} -maxdepth ${depth} -mtime +${env.DAYS_OLD} -type f -exec rm -f {} + || echo "Some files could not be deleted due to permissions"
208213

209214
echo "Cleanup completed for ${dir}"
210215
"""

0 commit comments

Comments
 (0)