Jenkinsfile 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 compile'
  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 'touch build.tar.gz' // Avoid tar warning about files changing during read
  47. sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
  48. }
  49. }
  50. stage('Publish') {
  51. steps {
  52. withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
  53. s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
  54. }
  55. }
  56. }
  57. }
  58. post {
  59. failure {
  60. mail(from: "${EMAIL_ALERT_FROM}",
  61. to: "${EMAIL_ALERT_TO}",
  62. subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
  63. body: "Build: ${BUILD_URL}")
  64. }
  65. }
  66. // The options directive is for configuration that applies to the whole job.
  67. options {
  68. // we'd like to make sure remove old builds, so we don't fill up our storage!
  69. buildDiscarder(logRotator(numToKeepStr:'50'))
  70. // And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
  71. timeout(time: 30, unit: 'MINUTES')
  72. }
  73. }