Skip to content

Instantly share code, notes, and snippets.

@sixeyed
Created June 24, 2019 17:15
Show Gist options
  • Save sixeyed/87e72b57b9cdd0979853883ad752dc88 to your computer and use it in GitHub Desktop.
Save sixeyed/87e72b57b9cdd0979853883ad752dc88 to your computer and use it in GitHub Desktop.
Jenkins snippet for remote building on a Docker Swarm node
build_and_push() {
ip=$1
os=$2
arch=$3
docker \
--host tcp://$ip:2376 --tlsverify --tlscacert $ca --tlscert $cert --tlskey $key \
image build --pull -t org/repo:$os-$arch .
docker \
--host tcp://$ip:2376 --tlsverify --tlscacert $ca --tlscert $cert --tlskey $key \
login -u $hub_user -p $hub_password
docker \
--host tcp://$ip:2376 --tlsverify --tlscacert $ca --tlscert $cert --tlskey $key \
image push org/repo:$os-$arch
}
cd ./windows
winIp=$(nslookup windows.amd64.workers.swarm.sixeyed | tail -n1 | grep Address | awk '{printf ($3" ")}' | tr -d ' ')
build_and_push $winIp 'windows' 'amd64'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment