Use S3 for CI repositories
Upload artifacts from the mock builds into S3 to allow us to burst into AWS when needed. Signed-off-by: Major Hayden <major@redhat.com>
This commit is contained in:
parent
d65057e164
commit
c8666061f0
2 changed files with 47 additions and 38 deletions
|
|
@ -9,12 +9,34 @@ function greenprint {
|
|||
# Get OS details.
|
||||
source /etc/os-release
|
||||
|
||||
# Set variables.
|
||||
CONTAINER=osbuildci-artifacts
|
||||
# Install s3cmd if it is not present.
|
||||
if ! s3cmd --version; then
|
||||
greenprint "📦 Installing s3cmd"
|
||||
sudo pip3 install s3cmd
|
||||
fi
|
||||
|
||||
# Jenkins sets a workspace variable as the root of its working directory.
|
||||
WORKSPACE=${WORKSPACE:-$(pwd)}
|
||||
|
||||
# Mock configuration file to use for building RPMs.
|
||||
MOCK_CONFIG="${ID}-${VERSION_ID%.*}-$(uname -m)"
|
||||
|
||||
# Jenkins takes the proposed PR and merges it onto master. Although this
|
||||
# creates a new SHA (which is slightly confusing), it ensures that the code
|
||||
# merges properly against master and it tests the code against the latest
|
||||
# commit in master, which is certainly good.
|
||||
POST_MERGE_SHA=$(git rev-parse --short HEAD)
|
||||
|
||||
# Bucket in S3 where our artifacts are uploaded
|
||||
REPO_BUCKET=osbuild-composer-repos
|
||||
|
||||
# Public URL for the S3 bucket with our artifacts.
|
||||
MOCK_REPO_BASE_URL="http://osbuild-composer-repos.s3-website.us-east-2.amazonaws.com"
|
||||
|
||||
# Directory to hold the RPMs temporarily before we upload them.
|
||||
REPO_DIR=repo/${JOB_NAME}/${POST_MERGE_SHA}/${ID}${VERSION_ID//./}
|
||||
|
||||
# Full URL to the RPM repository after they are uploaded.
|
||||
REPO_URL=${MOCK_REPO_BASE_URL}/${JOB_NAME}/${POST_MERGE_SHA}/${ID}${VERSION_ID//./}
|
||||
|
||||
# Print some data.
|
||||
|
|
@ -49,16 +71,10 @@ mv ${REPO_DIR}/*.log $WORKSPACE
|
|||
greenprint "⛓️ Creating dnf repository"
|
||||
createrepo_c ${REPO_DIR}
|
||||
|
||||
# Prepare to upload to swift.
|
||||
greenprint "🛂 Setting up OpenStack authentication credentials"
|
||||
mkdir -p ~/.config/openstack
|
||||
cp $OPENSTACK_CREDS ~/.config/openstack/clouds.yml
|
||||
export OS_CLOUD=psi
|
||||
|
||||
# Upload repository to swift.
|
||||
greenprint "☁ Uploading RPMs to OpenStack object storage"
|
||||
# Upload repository to S3.
|
||||
greenprint "☁ Uploading RPMs to S3"
|
||||
pushd repo
|
||||
find * -type f -print | xargs openstack object create -f value $CONTAINER
|
||||
s3cmd --acl-public sync . s3://${REPO_BUCKET}/
|
||||
popd
|
||||
|
||||
# Create a repository file.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue