Jenkinsfile 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. pipeline {
  2. agent any
  3. triggers {
  4. pollSCM('* * * * *')
  5. cron('@daily')
  6. }
  7. stages {
  8. stage('Install') {
  9. agent {
  10. docker {
  11. image 'node:4.2.1'
  12. args "-v /var/lib/jenkins/.npm:/tmp/.npm -e HOME=/tmp"
  13. reuseNode true
  14. }
  15. }
  16. steps {
  17. // we need to disable logallrefupdates, else git clones during the npm install will require git to lookup the user id
  18. // which does not exist in the container's /etc/passwd file, causing the clone to fail.
  19. sh 'git config --global core.logallrefupdates false'
  20. sh 'rm -fr node_modules'
  21. sh 'npm install && npm rebuild'
  22. sh 'npm install --quiet grunt-cli'
  23. }
  24. }
  25. stage('Compile and Test') {
  26. agent {
  27. docker {
  28. image 'node:4.2.1'
  29. reuseNode true
  30. }
  31. }
  32. steps {
  33. sh 'node_modules/.bin/grunt coffee'
  34. sh 'node_modules/.bin/grunt compile:acceptance_tests'
  35. sh 'NODE_ENV=development node_modules/.bin/grunt test:unit'
  36. }
  37. }
  38. stage('Acceptance Tests') {
  39. steps {
  40. sh 'docker pull sharelatex/acceptance-test-runner'
  41. sh 'docker run --rm -v $(pwd):/app sharelatex/acceptance-test-runner'
  42. }
  43. }
  44. stage('Package') {
  45. steps {
  46. sh 'echo ${BUILD_NUMBER} > build_number.txt'
  47. sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
  48. sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
  49. }
  50. }
  51. stage('Publish') {
  52. steps {
  53. withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
  54. s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
  55. // The deployment process uses this file to figure out the latest build
  56. s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
  57. }
  58. }
  59. }
  60. }
  61. post {
  62. failure {
  63. mail(from: "${EMAIL_ALERT_FROM}",
  64. to: "${EMAIL_ALERT_TO}",
  65. subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
  66. body: "Build: ${BUILD_URL}")
  67. }
  68. }
  69. // The options directive is for configuration that applies to the whole job.
  70. options {
  71. // we'd like to make sure remove old builds, so we don't fill up our storage!
  72. buildDiscarder(logRotator(numToKeepStr:'50'))
  73. // And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
  74. timeout(time: 30, unit: 'MINUTES')
  75. }
  76. }