Jenkinsfile 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
  2. pipeline {
  3. agent any
  4. triggers {
  5. pollSCM('* * * * *')
  6. cron(cron_string)
  7. }
  8. stages {
  9. stage('Build') {
  10. steps {
  11. sh 'make build'
  12. }
  13. }
  14. stage('Unit Tests') {
  15. steps {
  16. sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
  17. }
  18. }
  19. stage('Acceptance Tests') {
  20. steps {
  21. withCredentials([usernamePassword(credentialsId: 'S3_DOCSTORE_TEST_AWS_KEYS', passwordVariable: 'AWS_SECRET_ACCESS_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
  22. sh 'AWS_BUCKET="sl-doc-archive-testing" AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
  23. }
  24. }
  25. }
  26. stage('Package and publish build') {
  27. steps {
  28. sh 'make publish'
  29. }
  30. }
  31. stage('Publish build number') {
  32. steps {
  33. sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
  34. withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
  35. // The deployment process uses this file to figure out the latest build
  36. s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
  37. }
  38. }
  39. }
  40. }
  41. post {
  42. always {
  43. sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
  44. }
  45. failure {
  46. mail(from: "${EMAIL_ALERT_FROM}",
  47. to: "${EMAIL_ALERT_TO}",
  48. subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
  49. body: "Build: ${BUILD_URL}")
  50. }
  51. }
  52. // The options directive is for configuration that applies to the whole job.
  53. options {
  54. // we'd like to make sure remove old builds, so we don't fill up our storage!
  55. buildDiscarder(logRotator(numToKeepStr:'50'))
  56. // And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
  57. timeout(time: 30, unit: 'MINUTES')
  58. }
  59. }