-
Notifications
You must be signed in to change notification settings - Fork 3
/
run-test.sh
executable file
·31 lines (22 loc) · 990 Bytes
/
run-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/bash
function _() {
echo "==> $@"
}
_ "[FAKE] Talking to Jenkins: Please, test the repository ${SOURCE_REPOSITORY_URL}, tests are located in ${REPO_TEST_PATH}"
_ "[FAKE] Jenkins running..."
_ "[FAKE] Jenkins returned: PASS"
if [[ -d /var/run/secrets/openshift.io/push ]] && [[ ! -e /root/.dockercfg ]]; then
cp /var/run/secrets/openshift.io/push/.dockercfg /root/.dockercfg
fi
FULL_FROM=${OUTPUT_REGISTRY}/`python -c 'import json, os; print json.loads(os.environ["BUILD"])["metadata"]["namespace"]'`/${FROM}
FULL_TO=`python -c 'import json, os; print json.loads(os.environ["BUILD"])["spec"]["output"]["to"]["name"]'`
_ "Pulling tested image (${FULL_FROM})"
docker pull ${FULL_FROM}
_ "Re-tagging tested image (${FULL_FROM} -> ${TO})"
docker tag ${FULL_FROM} ${FULL_TO}
_ "Pushing the image to registry (${FULL_TO})"
if [ -n "${FULL_TO}" ] || [ -s "/root/.dockercfg" ]; then
docker push "${FULL_TO}"
fi
_ "Cleaning environment"
docker rmi ${FULL_FROM} ${FULL_TO}