Skip to content

Commit

Permalink
Fixing script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mihxil committed Sep 19, 2024
1 parent 627dab3 commit 54c33f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ LABEL maintainer=digitaal-techniek@vpro.nl
ENV YQ_VERSION=v4.44.3
ENV YQ_BINARY=yq_linux_amd64

ADD entrypoint.sh /root/entrypoint.sh

RUN apt-get -y update && apt-get -y upgrade && apt-get install -y wget ssh git rsync file && \
apt-get clean && rm -rf /var/lib/apt/lists/* && \
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY}.tar.gz -O - | tar xz && mv ${YQ_BINARY} /usr/bin/yq && \
Expand All @@ -25,7 +27,6 @@ RUN apt-get -y update && apt-get -y upgrade && apt-get install -y wget ssh git r

WORKDIR /root

ADD entrypoint.sh /root/entrypoint.sh
ADD after_maven.sh /root/after_maven.sh

ENTRYPOINT ["/root/entrypoint.sh"]
21 changes: 14 additions & 7 deletions after_maven.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
echo "PROJECT_VERSION="$(mvn -ntp help:evaluate -Dexpression=project.version -q -DforceStdout) | tee -a job.env
setProperty(){
if [ ! -e $3 ] ; then
touch $3
fi
awk -v pat="^$1=" -v value="$1=$2" 'BEGIN {found=0; } { if ($0 ~ pat) { found=1; print value; } else print $0; } END { if (! found) print value }' $3 > $3.tmp
mv -f $3.tmp $3 >/dev/null
}

setProperty "PROJECT_VERSION" "$(mvn -ntp help:evaluate -Dexpression=project.version -q -DforceStdout)" job.env
counts=($(for d in `find . -name 'surefire-reports' -print` ; do cat $d/*.txt 2>/dev/null ; done | grep -E "^Tests run:" | awk -F'[, ]+' 'BEGIN {t=0; f=0; e=0; s=0} {t+=$3; f+=$5; e+=$7; s+=$9} END {print t"\t"f"\t"e"\t"s}'))

echo "JOB_ID_BUILD_STAGE=$CI_JOB_ID" | tee -a job.env
echo "MAVEN_TESTS_RUN=${counts[0]}" | tee -a job.env
echo "MAVEN_TESTS_FAILED=${counts[1]}" | tee -a job.env
echo "MAVEN_TESTS_ERROR=${counts[2]}" | tee -a job.env
echo "MAVEN_TESTS_SKIPPED=${counts[3]}" | tee -a job.env
setProperty "JOB_ID_BUILD_STAGE" "$CI_JOB_ID" job.env
setProperty "MAVEN_TESTS_RUN" "${counts[0]}" job.env
setProperty "MAVEN_TESTS_FAILED" "${counts[1]}" job.env
setProperty "MAVEN_TESTS_ERROR" "${counts[2]}" job.env
setProperty "MAVEN_TESTS_SKIPPED" "${counts[3]}" job.env


# make sure some files exist otherwise 'reports' gets confused
Expand All @@ -15,7 +23,6 @@ if [ ${counts[0]} -eq 0 ]; then
mkdir -p a/target/failsafe-reports ; echo '<testsuite />' > a/target/surefire-reports/TEST-empty.xml
fi

sort -u -o job.env job.env
wc -l job.env

if [ -d target/site ]; then
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ ! -z ${GITLAB_RUNNER_PRIVATE_KEY+x} ];
then
echo Starting agent and adding key
eval $(ssh-agent -s)
eval "$(ssh-agent -s)"
ssh-add <(echo "$GITLAB_RUNNER_PRIVATE_KEY")
fi

Expand Down

0 comments on commit 54c33f5

Please sign in to comment.