Skip to content

Commit fc8d0eb

Browse files
committed
AG-49285 Refactor Bamboo cleanup tasks to use centralized cleanup script
Squashed commit of the following: commit f81e45e Merge: c08d8cd 885667f Author: scripthunter7 <d.tota@adguard.com> Date: Wed Dec 10 12:27:52 2025 +0100 Merge branch 'master' into fix/AG-49285 commit c08d8cd Author: scripthunter7 <d.tota@adguard.com> Date: Wed Dec 10 09:06:40 2025 +0100 Refactor Bamboo cleanup tasks to use centralized cleanup script - Create bamboo-specs/scripts/cleanup.sh with artifact preservation support - Replace inline cleanup scripts across all Bamboo specs with calls to cleanup.sh - Add artifact preservation for .vsix files in build and build-prerelease specs - Add final-tasks cleanup step to increment.yaml - Include disk usage reporting and top 5 files listing in cleanup script - Implement temporary directory stashing mechanism to preserve specified artifacts during
1 parent 885667f commit fc8d0eb

7 files changed

Lines changed: 67 additions & 105 deletions

File tree

bamboo-specs/build-prerelease.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,7 @@ Build:
7575
- script:
7676
interpreter: SHELL
7777
scripts:
78-
- |-
79-
set -x
80-
set -e
81-
82-
# Fix mixed logs
83-
exec 2>&1
84-
85-
ls -la
86-
87-
echo "Size before cleanup:" && du -h | tail -n 1
88-
89-
# Cleanup
90-
pnpm clean
91-
92-
echo "Size after cleanup:" && du -h | tail -n 1
78+
- "./bamboo-specs/scripts/cleanup.sh out/vscode-adblock.vsix"
9379
# Store the .vsix file as a build artifact
9480
artifacts:
9581
- name: vscode-adblock.vsix

bamboo-specs/build.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,21 +73,7 @@ Build:
7373
- script:
7474
interpreter: SHELL
7575
scripts:
76-
- |-
77-
set -x
78-
set -e
79-
80-
# Fix mixed logs
81-
exec 2>&1
82-
83-
ls -la
84-
85-
echo "Size before cleanup:" && du -h | tail -n 1
86-
87-
# Cleanup
88-
pnpm clean
89-
90-
echo "Size after cleanup:" && du -h | tail -n 1
76+
- "./bamboo-specs/scripts/cleanup.sh out/vscode-adblock.vsix"
9177
# Store the .vsix file as a build artifact
9278
artifacts:
9379
- name: vscode-adblock.vsix

bamboo-specs/deploy-prerelease.yaml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,7 @@ marketplace.visualstudio.com:
4545
- script:
4646
interpreter: SHELL
4747
scripts:
48-
- |-
49-
set -x
50-
set -e
51-
52-
# Fix mixed logs
53-
exec 2>&1
54-
55-
ls -la
56-
57-
echo "Size before cleanup:" && du -h | tail -n 1
58-
59-
# cleanup
60-
pnpm clean
61-
62-
echo "Size after cleanup:" && du -h | tail -n 1
48+
- "./bamboo-specs/scripts/cleanup.sh"
6349
requirements:
6450
- adg-docker: 'true'
6551
notifications:
@@ -106,21 +92,7 @@ open-vsx.org:
10692
- script:
10793
interpreter: SHELL
10894
scripts:
109-
- |-
110-
set -x
111-
set -e
112-
113-
# Fix mixed logs
114-
exec 2>&1
115-
116-
ls -la
117-
118-
echo "Size before cleanup:" && du -h | tail -n 1
119-
120-
# Cleanup
121-
pnpm clean
122-
123-
echo "Size after cleanup:" && du -h | tail -n 1
95+
- "./bamboo-specs/scripts/cleanup.sh"
12496
requirements:
12597
- adg-docker: 'true'
12698
notifications:

bamboo-specs/deploy.yaml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,7 @@ marketplace.visualstudio.com:
4545
- script:
4646
interpreter: SHELL
4747
scripts:
48-
- |-
49-
set -x
50-
set -e
51-
52-
# Fix mixed logs
53-
exec 2>&1
54-
55-
ls -la
56-
57-
echo "Size before cleanup:" && du -h | tail -n 1
58-
59-
# cleanup
60-
pnpm clean
61-
62-
echo "Size after cleanup:" && du -h | tail -n 1
48+
- "./bamboo-specs/scripts/cleanup.sh"
6349
requirements:
6450
- adg-docker: 'true'
6551
notifications:
@@ -106,21 +92,7 @@ open-vsx.org:
10692
- script:
10793
interpreter: SHELL
10894
scripts:
109-
- |-
110-
set -x
111-
set -e
112-
113-
# Fix mixed logs
114-
exec 2>&1
115-
116-
ls -la
117-
118-
echo "Size before cleanup:" && du -h | tail -n 1
119-
120-
# Cleanup
121-
pnpm clean
122-
123-
echo "Size after cleanup:" && du -h | tail -n 1
95+
- "./bamboo-specs/scripts/cleanup.sh"
12496
requirements:
12597
- adg-docker: 'true'
12698
notifications:

bamboo-specs/increment.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ Increment:
4343
configuration:
4444
commitMessage: 'skipci: Automatic increment build number'
4545
selectedRepository: defaultRepository
46+
final-tasks:
47+
- script:
48+
interpreter: SHELL
49+
scripts:
50+
- "./bamboo-specs/scripts/cleanup.sh"
4651
requirements:
4752
- adg-docker: true
4853

bamboo-specs/scripts/cleanup.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
# Cleanup script that preserves specified artifacts
4+
# Usage: ./cleanup.sh "artifact1,artifact2,artifact3"
5+
6+
# 'set' should be added to the beginning of each script to ensure that it runs with the correct options.
7+
# Please do not move it to some common file, like `setup-tests.sh`, because sourcing A script from B script
8+
# cannot change the options of B script.
9+
# -e: Exit immediately if any command exits with a non-zero status (i.e., if a command fails).
10+
# -x: Print each command to the terminal as it is executed, which is useful for debugging.
11+
set -ex
12+
13+
# Fix mixed logs
14+
exec 2>&1
15+
16+
echo "Size before cleanup:" && du -h | tail -n 1
17+
echo "Top 5 files:" && du -h | sort -hr | head -n 5
18+
19+
# Parse artifacts from command line argument
20+
ARTIFACTS_ARG="${1:-}"
21+
if [ -z "$ARTIFACTS_ARG" ]; then
22+
echo "No artifacts specified, cleaning entire workspace"
23+
ARTIFACTS=""
24+
else
25+
# Convert comma-separated string to space-separated
26+
ARTIFACTS=$(echo "$ARTIFACTS_ARG" | tr ',' ' ')
27+
echo "Preserving artifacts: $ARTIFACTS"
28+
fi
29+
30+
TMP="$(mktemp -d)"
31+
trap 'rm -rf "$TMP"' EXIT
32+
33+
# Stash artifacts to /tmp
34+
for f in $ARTIFACTS; do
35+
[ -e "$f" ] || continue
36+
echo "Stashing artifact: $f"
37+
mkdir -p "$TMP/$(dirname "$f")"
38+
mv "$f" "$TMP/$f"
39+
done
40+
41+
# Clean entire workspace (including dotfiles and .git)
42+
find . -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +
43+
44+
# Restore artifacts
45+
for f in $ARTIFACTS; do
46+
[ -e "$TMP/$f" ] || continue
47+
echo "Restoring artifact: $f"
48+
mkdir -p "$(dirname "$f")"
49+
mv "$TMP/$f" "$f"
50+
done
51+
52+
echo "Size after cleanup:" && du -h | tail -n 1
53+
echo "Top 5 files:" && du -h | sort -hr | head -n 5
54+
55+
echo "Cleanup completed successfully"

bamboo-specs/test.yaml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,7 @@ Build:
5656
- script:
5757
interpreter: SHELL
5858
scripts:
59-
- |-
60-
set -x
61-
set -e
62-
63-
# Fix mixed logs
64-
exec 2>&1
65-
66-
ls -la
67-
68-
echo "Size before cleanup:" && du -h | tail -n 1
69-
70-
# Cleanup
71-
pnpm clean
72-
73-
echo "Size after cleanup:" && du -h | tail -n 1
59+
- "./bamboo-specs/scripts/cleanup.sh"
7460
requirements:
7561
- adg-docker: true
7662

0 commit comments

Comments
 (0)