Jenkinsfile 2.0 KB

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