Jenkinsfile 2.6 KB

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