Jenkinsfile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 'echo $AWS_ID | wc'
  23. 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'
  24. }
  25. }
  26. }
  27. stage('Package and publish build') {
  28. steps {
  29. sh 'make publish'
  30. }
  31. }
  32. stage('Publish build number') {
  33. steps {
  34. sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
  35. withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
  36. // The deployment process uses this file to figure out the latest build
  37. s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
  38. }
  39. }
  40. }
  41. }
  42. post {
  43. always {
  44. sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
  45. }
  46. failure {
  47. mail(from: "${EMAIL_ALERT_FROM}",
  48. to: "${EMAIL_ALERT_TO}",
  49. subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
  50. body: "Build: ${BUILD_URL}")
  51. }
  52. }
  53. // The options directive is for configuration that applies to the whole job.
  54. options {
  55. // we'd like to make sure remove old builds, so we don't fill up our storage!
  56. buildDiscarder(logRotator(numToKeepStr:'50'))
  57. // And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
  58. timeout(time: 30, unit: 'MINUTES')
  59. }
  60. }