def upload(self, step, buildIdFile, tgzFile):
# only upload if requested
if not self.canUploadJenkins():
return ""
# upload with curl if file does not exist yet on server
return "\n" + textwrap.dedent("""\
# upload artifact
cd $WORKSPACE
BOB_UPLOAD_BID="$(hexdump -ve '/1 "%02x"' {BUILDID}){GEN}"
BOB_UPLOAD_URL="{URL}/${{BOB_UPLOAD_BID:0:2}}/${{BOB_UPLOAD_BID:2:2}}/${{BOB_UPLOAD_BID:4}}{SUFFIX}"
if ! curl --output /dev/null --silent --head --fail "$BOB_UPLOAD_URL" ; then
BOB_UPLOAD_RSP=$(curl -sSgf -w '%{{http_code}}' -H 'If-None-Match: *' -T {RESULT} "$BOB_UPLOAD_URL" || true)
if [[ $BOB_UPLOAD_RSP != 2?? && $BOB_UPLOAD_RSP != 412 ]]; then
echo "Upload failed with code $BOB_UPLOAD_RSP"{FAIL}
fi
fi""".format(URL=self.__url.geturl(), BUILDID=quote(buildIdFile), RESULT=quote(tgzFile),
FAIL="" if self._ignoreErrors() else "; exit 1",
GEN=ARCHIVE_GENERATION, SUFFIX=ARTIFACT_SUFFIX))
评论列表
文章目录