Skip to content

Instantly share code, notes, and snippets.

@sixeyed
Created June 24, 2019 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sixeyed/1c633652de81ee5bc3630f05ac96b8af to your computer and use it in GitHub Desktop.
Save sixeyed/1c633652de81ee5bc3630f05ac96b8af 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