aboutsummaryrefslogtreecommitdiff
path: root/rpb-openembedded/publishers.sh
blob: ae0f6035a03dbfc5b66394a71c36b35f2f426013 (plain)
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
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

if [ -f ${WORKSPACE}/BUILD-INFO.txt ];then
    BUILD_INFO="--build-info ${WORKSPACE}/BUILD-INFO.txt"
else
    BUILD_INFO=""
fi

if [ -z "${DEPLOY_DIR_IMAGE}" ] || [ -z "${PUB_DEST}" ] || [ -z "${PUBLISH_SERVER}" ]
then
    echo "== missing publishing variables =="
    echo "DEPLOY_DIR_IMAGE = ${DEPLOY_DIR_IMAGE}"
    echo "PUB_DEST         = ${PUB_DEST}"
    echo "PUBLISH_SERVER   = ${PUBLISH_SERVER}"
    exit 1
fi

# Publish
test -d ${HOME}/bin || mkdir ${HOME}/bin
wget -q https://git.linaro.org/ci/publishing-api.git/blob_plain/HEAD:/linaro-cp.py -O ${HOME}/bin/linaro-cp.py
time python3 ${HOME}/bin/linaro-cp.py \
  --server ${PUBLISH_SERVER} \
  ${BUILD_INFO} \
  ${DEPLOY_DIR_IMAGE}/ ${PUB_DEST}

# Some (most?) of our OE jobs publish images in a $DISTRO subfolder, so we need
# to strip the folder when we create the 'latest' link
# However some job, build a single distro, and there is no such subfolder, in which
# case we want to link to use PUB_DEST directly.

# Warning. Bashism here. But we use bash, so.. use Bash regexp to catch if PUB_DEST
# ends with BUILD_NUMBER or not, and we catch trailing '/' just in case it's there
if [[ "$PUB_DEST" =~ ^.*/${BUILD_NUMBER}/?$ ]]; then
    time python3 ${HOME}/bin/linaro-cp.py \
	 --server ${PUBLISH_SERVER} \
	 --make-link ${PUB_DEST}
else
    time python3 ${HOME}/bin/linaro-cp.py \
	 --server ${PUBLISH_SERVER} \
	 --make-link $(dirname ${PUB_DEST})
fi