Advertisement
Guest User

Untitled

a guest
Apr 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.82 KB | None | 0 0
  1. node {
  2.   githubCheckout()
  3.  
  4.   githubOnlyStage 'install npm deps', {
  5.     shell 'npm install'
  6.   }
  7.  
  8.   s3PublishOpsAssets([
  9.     'deploy/immunio-deploy.yaml',
  10.   ])
  11.  
  12.   stash name: 'node_modules', includes: 'node_modules/**'
  13. }
  14.  
  15. def builds = [:]
  16. builds['unit tests'] = {
  17.   node {
  18.     githubCheckout()
  19.  
  20.     unstash 'node_modules'
  21.  
  22.     githubOnlyStage 'unit tests', {
  23.       withSauceCredentials {
  24.         shell 'npm run test-headless'
  25.       }
  26.     }
  27.   }
  28. }
  29.  
  30. builds['e2e tests (debug)'] = {
  31.   node {
  32.     githubCheckout()
  33.  
  34.     unstash 'node_modules'
  35.  
  36.     githubOnlyStage 'e2e tests (debug)', {
  37.       withSauceCredentials {
  38.         shell 'bash -x test-config/jenkins.sh e2e-headless'
  39.       }
  40.     }
  41.  
  42.     publishWwwAssets('debug')
  43.   }
  44. }
  45.  
  46. builds['e2e tests (prod)'] = {
  47.   node {
  48.     githubCheckout()
  49.  
  50.     unstash 'node_modules'
  51.  
  52.     githubOnlyStage 'e2e tests (prod)', {
  53.       withSauceCredentials {
  54.         shell 'bash -x test-config/jenkins.sh e2e-headless:prod'
  55.       }
  56.     }
  57.  
  58.     publishWwwAssets('prod')
  59.   }
  60. }
  61.  
  62. stage 'build in parallel'
  63. parallel builds
  64.  
  65. stage 'publish'
  66. node {
  67.   githubCheckout()
  68.  
  69.   publishBuildManifest([])
  70. }
  71.  
  72. def publishWwwAssets(target) {
  73.   def buildDir = "build/${target}"
  74.   shell """
  75.    mkdir -p ${buildDir}
  76.    cp -a www ${buildDir}
  77.  """
  78.   archive "${buildDir}/www/**/*.*"
  79.  
  80.   def deployBucket = "build.us-west-2.immun.io"
  81.   def assetDir = "${env.JOB_NAME.tokenize('/')[1]}/${env.BRANCH_NAME}/${env.BUILD_NUMBER}/dashboard_files/${target}"
  82.   def s3Url = "s3://${deployBucket}/${assetDir}"
  83.  
  84.   echo "Uploading assets to ${s3Url}"
  85.  
  86.   withAwsOpsCredentials {
  87.     shell """
  88.      aws --region us-west-2 s3 cp www/ ${s3Url} --recursive --exclude index.html
  89.      aws --region us-west-2 s3 cp www/index.html ${s3Url}/index.html --cache-control max-age=0
  90.    """
  91.   }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement