From 117a28b62b63bbd2f21440b339c826edd3088224 Mon Sep 17 00:00:00 2001 From: matt Date: Sun, 18 Oct 2026 00:46:48 -0700 Subject: [PATCH] jenkinsfile - watch screen test 3 --- api/Jenkinsfile.ble_test | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/api/Jenkinsfile.ble_test b/api/Jenkinsfile.ble_test index 1903f6d..88dd818 100644 --- a/api/Jenkinsfile.ble_test +++ b/api/Jenkinsfile.ble_test @@ -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 + """ + } + } + } } \ No newline at end of file