From 950a03736009f1873f9e4c8b99fec4d97ca39b0c Mon Sep 17 00:00:00 2001 From: reinaortega Date: Fri, 25 Jun 2021 11:43:06 +0200 Subject: [PATCH] Enhancement of Jenkins build scripts for: 1) Detection of branch that triggers the build to determine whether or not to generate the .docx documents 2) Check for udpates on the robot2doc tool 3) Removal of precedent existing .docx documents in the workspace before running a new job --- .jenkins.sh | 4 +++- scripts/docker/Dockerfile | 2 ++ scripts/run-container.sh | 4 +++- scripts/validate.sh | 14 +++++++++++--- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/.jenkins.sh b/.jenkins.sh index 3bad4e68..010affd4 100644 --- a/.jenkins.sh +++ b/.jenkins.sh @@ -9,8 +9,10 @@ cd "$(dirname "$0")" run_dir="$(pwd)" +echo "Using git branch $GIT_BRANCH" + bash ./scripts/build-container.sh -bash ./scripts/run-container.sh "${run_dir}" +bash ./scripts/run-container.sh "${run_dir}" "$GIT_BRANCH" ret=$? echo "Final validation result: $ret" diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 9f753df8..bf5f1801 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -35,6 +35,8 @@ ADD extensions /home/etsi/dev/robot/extensions RUN ls /home/etsi/dev/robot +#To avoid to use the cache when new commits are available +ADD "https://forge.etsi.org/rep/api/v4/projects/224/repository/branches/master" /tmp/devalidateCache RUN DEBIAN_FRONTED=noninteractive \ cd /home/etsi/dev/ \ diff --git a/scripts/run-container.sh b/scripts/run-container.sh index c0ea0969..af5a8eb9 100644 --- a/scripts/run-container.sh +++ b/scripts/run-container.sh @@ -7,8 +7,10 @@ mkdir -p build +echo "Using git branch $2" + docker run -v "$(pwd)/build:/home/etsi/dev/build" stf583-rf-validation:latest "bash" \ - -c "/home/etsi/dev/robot/scripts/validate.sh" + -c "/home/etsi/dev/robot/scripts/validate.sh $2" ret=$? diff --git a/scripts/validate.sh b/scripts/validate.sh index ae06e2ea..4dbb7be4 100644 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -17,11 +17,19 @@ for i in */*/*.robot ; do fi done -cd /home/etsi/dev/robot2doc/robot2doc +echo "Using git branch $1" mkdir -p /home/etsi/dev/build +cd /home/etsi/dev/build +rm -r -v * -python3 create_sols.py ../../robot 'local' ../../build -res2=$? +if [[ "$1" =~ .*-dev$ || "$1" =~ \d+(\.?\d)+ || "$1" == "master" ]]; then + + cd /home/etsi/dev/robot2doc/robot2doc + + python3 create_sols.py ../../robot 'local' ../../build + res2=$? +else res=0 +fi exit $res && $res2 -- GitLab