You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

  1. #!groovy
  2. node {
  3. def deployable_branches = ["master"]
  4. stage('Checkout') {
  5. checkout scm
  6. }
  7. dockerStage('Build') {
  8. echo "Branch is: ${env.BRANCH_NAME}"
  9. echo "Build is: ${env.BUILD_NUMBER}"
  10. sh('''
  11. ./develop.sh sanity
  12. ./develop.sh build prod
  13. ./develop.sh build latest
  14. ''')
  15. }
  16. if (deployable_branches.contains(env.BRANCH_NAME)) {
  17. dockerStage('Publish') {
  18. withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'dockerbot',
  19. usernameVariable: 'DOCKER_USERNAME',
  20. passwordVariable: 'DOCKER_PASSWORD']]) {
  21. sh("""
  22. docker login -u "${env.DOCKER_USERNAME}" --password="${env.DOCKER_PASSWORD}"
  23. ./develop.sh push prod
  24. ./develop.sh push latest
  25. """)
  26. }
  27. }
  28. }
  29. }
  30. /*
  31. * dockerStage
  32. *
  33. * Custom stage that wraps the stage in timestamps and AnsiColorBuildWrapper
  34. * Prior to exit wrfy is used to kill all running containers and cleanup.
  35. */
  36. def dockerStage(String label,
  37. List<String> artifacts=[],
  38. List<String> testResults=[],
  39. Closure body) {
  40. stage(label) {
  41. try {
  42. timestamps {
  43. wrap([$class: 'AnsiColorBuildWrapper', 'colorMapName': 'XTerm']) {
  44. body.call()
  45. }
  46. }
  47. } catch (Exception e) {
  48. currentBuild.result = 'FAILURE'
  49. throw e
  50. } finally {
  51. for (artifact in artifacts) {
  52. step([$class: 'ArtifactArchiver', artifacts: artifact, fingerprint: false, excludes: null])
  53. }
  54. for (testResult in testResults) {
  55. step([$class: 'JUnitResultArchiver', testResults: testResult])
  56. }
  57. sh('''
  58. /env/bin/wrfy kill-all --force
  59. /env/bin/wrfy scrub --force
  60. ''')
  61. }
  62. }
  63. }