jenkinsfile - watch screen test 3

This commit is contained in:
matt committed 2026-10-18 00:46:48 -07:00
1 parent 4679c1629f
commit 117a28b62b
1 file changed
+17 -21
+17 -21
View File
@@ -26,17 +26,17 @@ pipeline {
// ---------------------------------------------------------------------
// 1. Build a unique screen session name
// ---------------------------------------------------------------------
stage('Prepare Screen Name') {
stage('Prepare Test Hash') {
steps {
script {
// epoch seconds as a plain long
long epochSec = System.currentTimeMillis() / 1000L
// keep only the last 6 digits → guarantees uniqueness
env.SCREEN_SESSION =
env.TEST_HASH =
"ble_test_${String.format('%06d', epochSec % 1_000_000)}"
sh "echo Screen ID - ${env.SCREEN_SESSION}"
sh "echo Test Hash - ${env.TEST_HASH}"
}
}
}
@@ -72,13 +72,9 @@ pipeline {
sleep 5
cd /opt/ble-test/ble_api
git pull
# Start test in detached screen
cd /opt/ble-test/ble_api/api
python3 -u ./ble.py ${params.test_count}
#screen -dmS ${env.SCREEN_SESSION} bash -c '
#'
echo "=== Live test output ==="
tail -f ~/screen/S.${env.SCREEN_SESSION}
screen -dmS test bash -c "cd /opt/ble-test/ble_api/api && python3 -u ./ble.py ${params.test_count} | tee /tmp/ble_test_${env.TEST_HASH}.log"
tail -f /tmp/ble_test_${env.TEST_HASH}.log
"""
}
}
@@ -90,16 +86,16 @@ pipeline {
// ---------------------------------------------------------------------
// Post‑build cleanup - kill the remote screen session
// ---------------------------------------------------------------------
post {
always {
sshagent([env.SSH_CREDENTIALS_ID]) {
sh """
ssh -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF
if screen -list | grep -q ${env.SCREEN_SESSION}; then
screen -S ${env.SCREEN_SESSION} -X quit
fi
"""
}
}
}
post {
always {
sshagent([env.SSH_CREDENTIALS_ID]) {
sh """
ssh -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF
if screen -list | grep -q ${env.TEST_HASH}; then
screen -S ${env.TEST_HASH} -X quit
fi
"""
}
}
}
}