Jenkinsfile.bkp 1.49 KB
pipeline {
    agent any

    environment { 
        registry = "israeldoamaral/app01" 
        registryCredential = 'dockerhub_id' 
        dockerImage = '' 
    }

    stages {
        // stage('Clone Repository') {
        //     steps {
        //         git url: 'http://cidsrvgit.cidades/israel/app01.git'
        //     }
        // }
        stage('Build Docker Image') {
            steps {
                script {
                    dockerImage = docker.build registry + ":develop"
                }
            }
        }
        stage('Send image to Docker Hub') {
            steps {
                script {
                    docker.withRegistry( '', registryCredential ) { 
                    dockerImage.push() 
                    }
                }
            }
        }
        stage('Cleaning up') {
            steps {
                sh "docker rmi $registry:develop"
            }
        }
    }
}
def remote = [:]
    remote.name = "suporte"
    remote.host = "172.25.45.103"
    remote.allowAnyHosts = true

    node {
        withCredentials([sshUserPrivateKey(credentialsId: 'suporte-id', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'suporte')]) {
            remote.user = suporte
            remote.identityFile = identity
            stage("SSH Steps Rocks!") {
            sshScript remote: remote, script: 'scripts/stop-container.sh'
            sshScript remote: remote, script: 'scripts/start-container.sh'
            
           }
       }    
   }