20 lines
960 B
Plaintext
20 lines
960 B
Plaintext
pipeline {
|
|
agent { label 'assignment8-trusted' }
|
|
options { skipDefaultCheckout(); timeout(time: 5, unit: 'MINUTES') }
|
|
stages {
|
|
stage('Checkout') { steps { checkout scm } }
|
|
stage('Authenticate target registry reader') {
|
|
steps {
|
|
withCredentials([sshUserPrivateKey(credentialsId: 'assignment8-deploy-ssh', keyFileVariable: 'DEPLOY_KEY', usernameVariable: 'DEPLOY_USER'), usernamePassword(credentialsId: 'assignment8-registry-read', usernameVariable: 'REG_USER', passwordVariable: 'REG_TOKEN')]) {
|
|
sh '''#!/bin/sh
|
|
set +x
|
|
set -eu
|
|
case "$REG_USER" in *[!a-zA-Z0-9_.-]*|'') echo 'Invalid registry username' >&2; exit 1;; esac
|
|
printf '%s' "$REG_TOKEN" | ssh -o BatchMode=yes -o StrictHostKeyChecking=yes -o UserKnownHostsFile="$WORKSPACE/secure-delivery/ansible/known_hosts" -i "$DEPLOY_KEY" "$DEPLOY_USER@172.20.0.1" "sudo -n docker login myfileagent.tech --username $REG_USER --password-stdin"
|
|
'''
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|