Created
          June 24, 2019 17:15 
        
      - 
      
- 
        Save sixeyed/1c633652de81ee5bc3630f05ac96b8af to your computer and use it in GitHub Desktop. 
    Jenkins snippet for remote building on a Docker Swarm node
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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