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 // 1. Build a unique screen session name
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
stage('Prepare Screen Name') { stage('Prepare Test Hash') {
steps { steps {
script { script {
// epoch seconds as a plain long // epoch seconds as a plain long
long epochSec = System.currentTimeMillis() / 1000L long epochSec = System.currentTimeMillis() / 1000L
// keep only the last 6 digits → guarantees uniqueness // keep only the last 6 digits → guarantees uniqueness
env.SCREEN_SESSION = env.TEST_HASH =
"ble_test_${String.format('%06d', epochSec % 1_000_000)}" "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 sleep 5
cd /opt/ble-test/ble_api cd /opt/ble-test/ble_api
git pull git pull
# Start test in detached screen
cd /opt/ble-test/ble_api/api cd /opt/ble-test/ble_api/api
python3 -u ./ble.py ${params.test_count} 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"
#screen -dmS ${env.SCREEN_SESSION} bash -c ' tail -f /tmp/ble_test_${env.TEST_HASH}.log
#'
echo "=== Live test output ==="
tail -f ~/screen/S.${env.SCREEN_SESSION}
""" """
} }
} }
@@ -90,16 +86,16 @@ pipeline {
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// Post‑build cleanup - kill the remote screen session // Post‑build cleanup - kill the remote screen session
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
post { post {
always { always {
sshagent([env.SSH_CREDENTIALS_ID]) { sshagent([env.SSH_CREDENTIALS_ID]) {
sh """ sh """
ssh -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF ssh -o StrictHostKeyChecking=no root@${params.host_ip} -o ServerAliveInterval=60 -o ServerAliveCountMax=120 << EOF
if screen -list | grep -q ${env.SCREEN_SESSION}; then if screen -list | grep -q ${env.TEST_HASH}; then
screen -S ${env.SCREEN_SESSION} -X quit screen -S ${env.TEST_HASH} -X quit
fi fi
""" """
} }
} }
} }
} }