Advertisement
Guest User

Jenkinsfile

a guest
Jun 19th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.99 KB | None | 0 0
  1. node {
  2.     def app
  3.     def local_container_name = "some-container-name"
  4.     def dockerhub_container = "user/${local_container_name}"
  5.     # So I can turn down old image and turn up new
  6.     def docker_compose_path = "/path/to/docker-compose/"
  7.  
  8.     stage('Clone Repository') {
  9.         checkout scm
  10.     }
  11.  
  12.     stage('Build Image') {
  13.         app = docker.build("${dockerhub_container}")
  14.     }
  15.  
  16.     stage('Test Image') {
  17.         # This allows you to run sh commands inside the container
  18.         app.inside {
  19.             sh 'echo "Volkswagen Tests passed"'
  20.         }
  21.     }
  22.  
  23.     stage('Push Image To Docker Hub') {
  24.         docker.withRegistry('https://registry.hub.docker.com', 'docker-hub-credentials') {
  25.             app.push("${env.BUILD_NUMBER}")
  26.             app.push("latest")
  27.         }
  28.     }
  29.  
  30.     stage ('SSH To Docker Host and Deploy') {
  31.         sshagent(credentials : ['my-ssh-creds']) {
  32.             sh '''
  33. SSH to@host <<EOF
  34. A Bunch Of SSH Commands
  35. EOF
  36. '''
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement