Răsfoiți Sursa

Merge pull request #3 from sharelatex/ja-oss-sync

Push master branch to public repo after successful build
James Allen 9 ani în urmă
părinte
comite
5a7e4f9fb0
1 a modificat fișierele cu 53 adăugiri și 6 ștergeri
  1. 53 6
      services/web/Jenkinsfile

+ 53 - 6
services/web/Jenkinsfile

@@ -1,11 +1,6 @@
 pipeline {
 pipeline {
   
   
-  agent {
-    docker {
-      image 'node:6.9.5'
-      args "-v /var/lib/jenkins/.npm:/tmp/.npm"
-    }
-  }
+  agent any
   
   
   environment  {
   environment  {
       HOME = "/tmp"
       HOME = "/tmp"
@@ -18,6 +13,12 @@ pipeline {
   
   
   stages {
   stages {
     stage('Set up') {
     stage('Set up') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          reuseNode true
+        }
+      }
       steps {
       steps {
         // we need to disable logallrefupdates, else git clones during the npm install will require git to lookup the user id
         // we need to disable logallrefupdates, else git clones during the npm install will require git to lookup the user id
         // which does not exist in the container's /etc/passwd file, causing the clone to fail.
         // which does not exist in the container's /etc/passwd file, causing the clone to fail.
@@ -40,11 +41,20 @@ pipeline {
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/learn-wiki'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@bitbucket.org:sharelatex/learn-wiki-web-module.git']]])
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/learn-wiki'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@bitbucket.org:sharelatex/learn-wiki-web-module.git']]])
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/templates'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/templates-webmodule.git']]])
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/templates'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/templates-webmodule.git']]])
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/track-changes'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/track-changes-web-module.git']]])
         checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/track-changes'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/track-changes-web-module.git']]])
+        checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'modules/overleaf-integration'], [$class: 'CloneOption', shallow: true]], userRemoteConfigs: [[credentialsId: 'GIT_DEPLOY_KEY', url: 'git@github.com:sharelatex/overleaf-integration-web-module.git']]])
       }
       }
     }
     }
     
     
     stage('Install') {
     stage('Install') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          args "-v /var/lib/jenkins/.npm:/tmp/.npm"
+          reuseNode true
+        }
+      }
       steps {
       steps {
+        sh 'git config --global core.logallrefupdates false'
         sh 'mv app/views/external/robots.txt public/robots.txt'
         sh 'mv app/views/external/robots.txt public/robots.txt'
         sh 'mv app/views/external/googlebdb0f8f7f4a17241.html public/googlebdb0f8f7f4a17241.html'
         sh 'mv app/views/external/googlebdb0f8f7f4a17241.html public/googlebdb0f8f7f4a17241.html'
         sh 'npm install'
         sh 'npm install'
@@ -56,24 +66,48 @@ pipeline {
     }
     }
 
 
     stage('Compile') {
     stage('Compile') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          reuseNode true
+        }
+      }
       steps {
       steps {
         sh 'node_modules/.bin/grunt compile  --verbose'
         sh 'node_modules/.bin/grunt compile  --verbose'
       }
       }
     }
     }
 
 
     stage('Smoke Test') {
     stage('Smoke Test') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          reuseNode true
+        }
+      }
       steps {
       steps {
         sh 'node_modules/.bin/grunt compile:smoke_tests'
         sh 'node_modules/.bin/grunt compile:smoke_tests'
       }
       }
     }
     }
 
 
     stage('Minify') {
     stage('Minify') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          reuseNode true
+        }
+      }
       steps {
       steps {
         sh 'node_modules/.bin/grunt compile:minify'
         sh 'node_modules/.bin/grunt compile:minify'
       }
       }
     }
     }
     
     
     stage('Unit Test') {
     stage('Unit Test') {
+      agent {
+        docker {
+          image 'node:6.9.5'
+          reuseNode true
+        }
+      }
       steps {
       steps {
         sh 'env NODE_ENV=development ./node_modules/.bin/grunt test:unit --reporter=tap'
         sh 'env NODE_ENV=development ./node_modules/.bin/grunt test:unit --reporter=tap'
       }
       }
@@ -87,6 +121,7 @@ pipeline {
         sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
         sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
       }
       }
     }
     }
+    
     stage('Publish') {
     stage('Publish') {
       steps {
       steps {
         withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
         withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
@@ -96,6 +131,18 @@ pipeline {
         }
         }
       }
       }
     }
     }
+    
+    
+    stage('Sync OSS') {
+      when {
+        branch 'master'
+      }
+      steps {
+        sshagent (credentials: ['GIT_DEPLOY_KEY']) {
+          sh 'git push git@github.com:sharelatex/web-sharelatex.git HEAD:master'
+        }
+      }
+    }
   }
   }
   
   
   post {
   post {