Skip to content

Commit

Permalink
pipeline-utils: add registry_login() utility function
Browse files Browse the repository at this point in the history
This adds a simple function to login to a container registry using
username, password, and registry name as args.
  • Loading branch information
miabbott committed Sep 25, 2018
1 parent 36b7f50 commit bf4aa4f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pipeline-utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,28 @@ def sh_capture(cmd) {
return sh(returnStdout: true, script: cmd).trim()
}

def registry_login(username, password, registry) {
sh "podman login -u '${username}' -p '${password}' ${registry}"
}

// re-implementation of some functionality from scripts/pull-mount-oscontainer
// takes a directory mounted in from the host, creates a new location to
// store containers, and bind mounts it to '/var/lib/containers`
def prep_container_storage(dirFromHost) {
sh """
container_storage="/var/lib/containers"
dest="${dirFromHost}/containers"
fstype=$(df -P ${dirFromHost} | awk 'END{print $6}' | xargs findmnt -n -o FSTYPE)
if [ "$fstype" == "overlay" ]; then
echo "Must supply non-overlay location"
exit 1
fi
rm -rf ${container_storage} && mkdir -p ${container_storage}
rm -rf ${dest} && mkdir -p ${dest}
mount --bind ${dest} ${container_storage}
"""
}

// Substitute secrets from credentials into files in the git repo
def prepare_configuration() {
withCredentials([
Expand Down

0 comments on commit bf4aa4f

Please sign in to comment.