Skip to content

Commit 2204a31

Browse files
ci: grab Docker containers logs (#719)
* feat: grab Docker containers logs * chore: cosmetic changes
1 parent 151f2ef commit 2204a31

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

Jenkinsfile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,22 @@ class PythonParallelTaskGenerator extends DefaultParallelTaskGenerator {
339339
} finally {
340340
steps.junit(allowEmptyResults: true,
341341
keepLongStdio: true,
342-
testResults: "**/python-agent-junit.xml,**/target/**/TEST-*.xml")
342+
testResults: "**/python-agent-junit.xml,**/target/**/TEST-*.xml"
343+
)
343344
steps.env.PYTHON_VERSION = "${x}"
344345
steps.env.WEBFRAMEWORK = "${y}"
345346
steps.codecov(repo: "${steps.env.REPO}",
346347
basedir: "${steps.env.BASE_DIR}",
347348
flags: "-e PYTHON_VERSION,WEBFRAMEWORK",
348-
secret: "${steps.env.CODECOV_SECRET}")
349+
secret: "${steps.env.CODECOV_SECRET}"
350+
)
351+
dir("${steps.env.BASE_DIR}/tests"){
352+
steps.archiveArtifacts(
353+
allowEmptyArchive: true,
354+
artifacts: '**/docker-info/**',
355+
defaultExcludes: false
356+
)
357+
}
349358
}
350359
}
351360
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
STEP=${1:-""}
5+
6+
DOCKER_INFO_DIR="docker-info/${STEP}"
7+
mkdir -p ${DOCKER_INFO_DIR}
8+
cp docker-compose.yml ${DOCKER_INFO_DIR}
9+
cd ${DOCKER_INFO_DIR}
10+
11+
docker ps -a &> docker-containers.txt
12+
13+
DOCKER_IDS=$(docker ps -aq)
14+
15+
for id in ${DOCKER_IDS}
16+
do
17+
docker ps -af id=${id} --no-trunc &> ${id}-cmd.txt
18+
docker logs ${id} &> ${id}.log || echo "It is not possible to grab the logs of ${id}"
19+
docker inspect ${id} &> ${id}-inspect.json || echo "It is not possible to grab the inspect of ${id}"
20+
done
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
DOCKER_IDS=$(docker ps -aq)
5+
6+
for id in ${DOCKER_IDS}
7+
do
8+
echo "***********************************************************"
9+
echo "***************Docker Container ${id}***************"
10+
echo "***********************************************************"
11+
docker ps -af id=${id} --no-trunc
12+
echo "----"
13+
docker logs ${id} | tail -n 10 || echo "It is not possible to grab the logs of ${id}"
14+
done
15+
16+
echo "*******************************************************"
17+
echo "***************Docker Containers Summary***************"
18+
echo "*******************************************************"
19+
docker ps -a

tests/scripts/docker/run_tests.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
set -ex
33

44
function cleanup {
5+
if [ -n "${BUILD_NUMBER}" ]; then # only on CI
6+
./scripts/docker/docker-summary.sh
7+
./scripts/docker/docker-get-logs.sh "${1}-${2}"
8+
fi
59
PYTHON_VERSION=${1} docker-compose down -v
610

711
if [[ $CODECOV_TOKEN ]]; then

0 commit comments

Comments
 (0)