Add new file
Showing
1 changed file
with
54 additions
and
0 deletions
Jenkinsfile
0 → 100644
| 1 | pipeline { | ||
| 2 | agent any | ||
| 3 | |||
| 4 | environment { | ||
| 5 | registry = "israeldoamaral/app01" | ||
| 6 | registryCredential = 'dockerhub_id' | ||
| 7 | dockerImage = '' | ||
| 8 | } | ||
| 9 | |||
| 10 | stages { | ||
| 11 | // stage('Clone Repository') { | ||
| 12 | // steps { | ||
| 13 | // git url: 'http://cidsrvgit.cidades/israel/app01.git' | ||
| 14 | // } | ||
| 15 | // } | ||
| 16 | stage('Build Docker Image') { | ||
| 17 | steps { | ||
| 18 | script { | ||
| 19 | dockerImage = docker.build registry + ":develop" | ||
| 20 | } | ||
| 21 | } | ||
| 22 | } | ||
| 23 | stage('Send image to Docker Hub') { | ||
| 24 | steps { | ||
| 25 | script { | ||
| 26 | docker.withRegistry( '', registryCredential ) { | ||
| 27 | dockerImage.push() | ||
| 28 | } | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | stage('Cleaning up') { | ||
| 33 | steps { | ||
| 34 | sh "docker rmi $registry:develop" | ||
| 35 | } | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | def remote = [:] | ||
| 40 | remote.name = "suporte" | ||
| 41 | remote.host = "172.25.45.103" | ||
| 42 | remote.allowAnyHosts = true | ||
| 43 | |||
| 44 | node { | ||
| 45 | withCredentials([sshUserPrivateKey(credentialsId: 'suporte-id', keyFileVariable: 'identity', passphraseVariable: '', usernameVariable: 'suporte')]) { | ||
| 46 | remote.user = suporte | ||
| 47 | remote.identityFile = identity | ||
| 48 | stage("SSH Steps Rocks!") { | ||
| 49 | sshScript remote: remote, script: 'scripts/stop-container.sh' | ||
| 50 | sshScript remote: remote, script: 'scripts/start-container.sh' | ||
| 51 | |||
| 52 | } | ||
| 53 | } | ||
| 54 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or sign in to post a comment