Skip to content

Commit

Permalink
Merge pull request #231 from dvsa/feat-vol-5246
Browse files Browse the repository at this point in the history
feat: updating docker build an push step in the workflow build job
  • Loading branch information
sdh100shaun authored May 29, 2024
2 parents 62cbdda + e10e473 commit a604382
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,6 @@ mockApiData
/Findings.txt

/LOGS

.env
.env.local
21 changes: 4 additions & 17 deletions infra/docker/batch/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
# FROM ghcr.io/dvsa/dvsa-docker-images/java/11/corretto AS base

FROM maven:3.9.6-amazoncorretto-11 as maven

# mvn clean verify -U -Denv=qa -Dbrowser=edge -DbrowserVersion=103 -Dplatform=LINUX -DgridURL=https://selenium-hub.olcs.dev-dvsacloud.uk/ '-Dtag.name=(not *)' -Dcucumber.filter.tags=@smoketest -Dwdm.proxy=proxy.ci.olcs.dev-dvsacloud.uk:3128 -Dhttps.proxyHost=proxy.ci.olcs.dev-dvsacloud.uk -Dhttps.proxyPort=3128 -Dhttp.proxyHost=proxy.ci.olcs.dev-dvsacloud.uk -Dhttp.proxyPort=3128 '-Dhttp.nonProxyHosts=172.17/12|localhost|127.0.0.1|*.olcs.dev-dvsacloud.uk'

ENV proxyHost=
ENV proxyPort=
ENV noProxyJava=
ENV platformEnv=
ENV browserName=
ENV browserVersion=
ENV platform=
ENV gridURL=https://selenium-hub.olcs.dev-dvsacloud.uk/
ENV exclude_tags=
ENV cucumberTags=



ENV platform="LINUX"
ENV gridURL="https://selenium-hub.olcs.dev-dvsacloud.uk/"

WORKDIR /app

Expand All @@ -35,4 +20,6 @@ COPY ./settings.xml ~/.m2/settings.xml

COPY . .

RUN chmod +x ./run.sh

CMD ["/bin/sh", "-c", "./run.sh"]
58 changes: 58 additions & 0 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
# Description: This script is used to run the tests in the docker container

# In environments some values are passed as environment variables to the container from the job definition
# they are set in the job definition others are set in the Dockerfile at build time or passed to
# the container at runtime via batch

# full list of environment variables passed to the container
# - platformEnv
# - browserName
# - browserVersion
# - platform
# - gridURL
# - exclude_tags
# - cucumberTags
# - resultsTargetBucket
# - resultsTargetBucketPath
# - resultsBuildNumber
# - RUN-BUILDID
# - proxyHost
# - proxyPort
# - noProxyJava
# - mavenOptions


# check if all the environment variables are set
check_environment_variables() {
# List of required environment variables
local required_vars=(
"platformEnv"
"browserName"
"browserVersion"
"platform"
"gridURL"
"exclude_tags"
"cucumberTags"
"resultsTargetBucket"
"resultsTargetBucketPath"
"resultsBuildNumber"
"RUN-BUILDID"
"proxyHost"
"proxyPort"
"noProxyJava"
"mavenOptions"
)

# Check if any of the required variables are not set
for var in "${required_vars[@]}"; do
if [[ -z "${!var}" ]]; then
echo "Error: Environment variable '$var' is not set."
return 1
fi
done

return 0
}

check_environment_variables || exit 1

# Echo the command to be captured in logs
echo "Now running [ mvn --batch-mode clean verify $mavenOptions -U -Dwdm.proxy=${proxyHost}:${proxyPort} -Dhttps.proxyHost=${proxyHost} -Dhttps.proxyPort=${proxyPort} -Dhttp.proxyHost=${proxyHost} -Dhttp.proxyPort=${proxyPort} -Dhttp.nonProxyHosts=${noProxyJava} -Denv=${platformEnv} -Dbrowser=${browserName} -DbrowserVersion=${browserVersion} -Dplatform=${platform} -DgridURL=_hidden_ -Dtag.name=\"(not ${exclude_tags})\" -Dcucumber.filter.tags=\"${cucumberTags}\" ] .."

Expand Down
1 change: 1 addition & 0 deletions setEnv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set -o allexport && source .env && set +o allexport

0 comments on commit a604382

Please sign in to comment.