67 lines
2.9 KiB
Bash
67 lines
2.9 KiB
Bash
#!/usr/bin/env bash
|
|
#
|
|
# Upload produced DEBs to the internal artifact repository and emit two
|
|
# helper files for the Jenkinsfile to consume (named per project + OS version):
|
|
# ${WORKSPACE}/url-${PROJECT}-${OS_VERSION}.txt — browseable URL of the uploaded folder
|
|
# ${WORKSPACE}/tdsversion-${PROJECT}-${OS_VERSION}.txt — full version string (LTS-build)
|
|
#
|
|
# Migrated from jenkins_publisher.sh (openSUSE) to Ubuntu/DEB ecosystem
|
|
#
|
|
# Required environment (set by the Jenkinsfile / withCredentials):
|
|
# PROJECT LTS flavor: ahtc | guez
|
|
# OS_VERSION Ubuntu base version, e.g. 26.04
|
|
# LTS_VERSION Major.minor LTS version, e.g. 1.0
|
|
# BUILD_NUMBER Jenkins build number (release component of the artifact name)
|
|
# WORKSPACE Jenkins workspace path
|
|
# ARTIFACTREPO Base URL of the internal repo (no trailing slash)
|
|
# ARTIFACTFOLDER Subfolder under cts-rpms/ (project name, e.g. qatar)
|
|
# CURL_CRED user:password for the upload (Jenkins credential)
|
|
#
|
|
|
|
set -eo pipefail
|
|
|
|
: "${PROJECT:?PROJECT must be set}"
|
|
: "${OS_VERSION:?OS_VERSION must be set}"
|
|
: "${LTS_VERSION:?LTS_VERSION must be set}"
|
|
: "${BUILD_NUMBER:?BUILD_NUMBER must be set}"
|
|
: "${WORKSPACE:?WORKSPACE must be set}"
|
|
: "${ARTIFACTREPO:?ARTIFACTREPO must be set}"
|
|
: "${ARTIFACTFOLDER:?ARTIFACTFOLDER must be set}"
|
|
: "${CURL_CRED:?CURL_CRED must be set}"
|
|
|
|
tds_folder_name="${PROJECT}-TDS-${LTS_VERSION}-${BUILD_NUMBER}"
|
|
tds_folder_path="${WORKSPACE}/rpms/${PROJECT}/${OS_VERSION}"
|
|
tds_artifact_store="${ARTIFACTREPO}/repository/cts-rpms/${ARTIFACTFOLDER}/${OS_VERSION}/${tds_folder_name}"
|
|
|
|
if [ ! -d "${tds_folder_path}/${tds_folder_name}" ]; then
|
|
echo "ERROR: expected package folder not found: ${tds_folder_path}/${tds_folder_name}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
shopt -s nullglob
|
|
uploaded=0
|
|
for file in "${tds_folder_path}/${tds_folder_name}"/*; do
|
|
[ -f "${file}" ] || continue
|
|
# Upload .deb, .dsc, .changes, .buildinfo files
|
|
if [[ "${file}" == *.deb ]] || [[ "${file}" == *.dsc ]] || [[ "${file}" == *.changes ]] || [[ "${file}" == *.buildinfo ]]; then
|
|
name=$(basename "${file}")
|
|
echo "Uploading: ${name}"
|
|
curl --fail --silent --show-error \
|
|
--user "${CURL_CRED}" \
|
|
--upload-file "${file}" \
|
|
"${tds_artifact_store}/${name}"
|
|
uploaded=$((uploaded + 1))
|
|
fi
|
|
done
|
|
|
|
if [ "${uploaded}" -eq 0 ]; then
|
|
echo "ERROR: no files uploaded from ${tds_folder_path}/${tds_folder_name}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Uploaded ${uploaded} file(s) to ${tds_artifact_store}/"
|
|
|
|
# Per-(project, OS) filenames so concurrent publish stages don't clobber each
|
|
# other's helper files; the Jenkinsfile reads back the matching names.
|
|
echo "${ARTIFACTREPO}/service/rest/repository/browse/cts-rpms/${ARTIFACTFOLDER}/${OS_VERSION}/${tds_folder_name}/" > "${WORKSPACE}/url-${PROJECT}-${OS_VERSION}.txt"
|
|
echo "${LTS_VERSION}-${BUILD_NUMBER}" > "${WORKSPACE}/tdsversion-${PROJECT}-${OS_VERSION}.txt" |