Advertisement
Guest User

Test declarative pipeline script

a guest
Dec 30th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.73 KB | None | 0 0
  1. pipeline {
  2.     agent none
  3.    
  4.     options {
  5.         disableConcurrentBuilds()
  6.     }
  7.    
  8.     stages {
  9.         stage('init & build') {
  10.             agent {
  11.                 docker {
  12.                     image 'node:12.14.0'
  13.                     args '--volume ${JENKINS_HOME}/workspace/${JOB_NAME}:/workspace'
  14.                 }
  15.             }
  16.             stages {
  17.                 stage('init') {
  18.                     steps {
  19.                         git branch: 'develop', url: 'https://github.com/wipcamp/12-game-pr.git'
  20.                         sh 'yarn'
  21.                     }
  22.                     post {
  23.                         success {
  24.                             echo "${env.JOB_NAME} successfully init!"
  25.                         }
  26.                     }
  27.                 }
  28.                 stage('build') {
  29.                     steps {
  30.                         catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
  31.                             sh 'yarn deploy'
  32.                         }
  33.                     }
  34.                     post {
  35.                         success {
  36.                             echo "${env.JOB_NAME} successfully built!"
  37.                         }
  38.                     }
  39.                 }
  40.             }
  41.         }
  42.      
  43.       stage('deploy') {
  44.           agent any
  45.           steps {
  46.             sh "ssh ${EDGE_JENKINS_USER}@${EDGE_MACHINE} 'cd /var/www/frontend/; rm -rf 12-game-pr'"
  47.             sh "scp -r build/ ${EDGE_JENKINS_USER}${EDGE_MACHINE}:/var/www/frontend/12-game-pr/"
  48.           }
  49.           post {
  50.             always {
  51.                 deleteDir()
  52.             }
  53.             success {
  54.                 echo "${env.JOB_NAME} successfully deploy!"
  55.             }
  56.          }
  57.       }
  58.    }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement