Jenkinsfile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!groovy
  2. def image
  3. def checkDocs = { ->
  4. wrappedNode(label: 'linux') {
  5. deleteDir(); checkout(scm)
  6. documentationChecker("docs")
  7. }
  8. }
  9. def buildImage = { ->
  10. wrappedNode(label: "ubuntu && !zfs", cleanWorkspace: true) {
  11. stage("build image") {
  12. deleteDir(); checkout(scm)
  13. def imageName = "dockerbuildbot/compose:${gitCommit()}"
  14. image = docker.image(imageName)
  15. try {
  16. image.pull()
  17. } catch (Exception exc) {
  18. image = docker.build(imageName, ".")
  19. image.push()
  20. }
  21. }
  22. }
  23. }
  24. def runTests = { Map settings ->
  25. def dockerVersions = settings.get("dockerVersions", null)
  26. def pythonVersions = settings.get("pythonVersions", null)
  27. if (!pythonVersions) {
  28. throw new Exception("Need Python versions to test. e.g.: `runTests(pythonVersions: 'py27,py34')`")
  29. }
  30. if (!dockerVersions) {
  31. throw new Exception("Need Docker versions to test. e.g.: `runTests(dockerVersions: 'all')`")
  32. }
  33. { ->
  34. wrappedNode(label: "ubuntu && !zfs", cleanWorkspace: true) {
  35. stage("test python=${pythonVersions} / docker=${dockerVersions}") {
  36. deleteDir(); checkout(scm)
  37. def storageDriver = sh(script: 'docker info | awk -F \': \' \'$1 == "Storage Driver" { print $2; exit }\'', returnStdout: true).trim()
  38. echo "Using local system's storage driver: ${storageDriver}"
  39. sh """docker run \\
  40. -t \\
  41. --rm \\
  42. --privileged \\
  43. --volume="\$(pwd)/.git:/code/.git" \\
  44. --volume="/var/run/docker.sock:/var/run/docker.sock" \\
  45. -e "TAG=${image.id}" \\
  46. -e "STORAGE_DRIVER=${storageDriver}" \\
  47. -e "DOCKER_VERSIONS=${dockerVersions}" \\
  48. -e "BUILD_NUMBER=\$BUILD_TAG" \\
  49. -e "PY_TEST_VERSIONS=${pythonVersions}" \\
  50. --entrypoint="script/ci" \\
  51. ${image.id} \\
  52. --verbose
  53. """
  54. }
  55. }
  56. }
  57. }
  58. def buildAndTest = { ->
  59. buildImage()
  60. // TODO: break this out into meaningful "DOCKER_VERSIONS" values instead of all
  61. parallel(
  62. failFast: true,
  63. all_py27: runTests(pythonVersions: "py27", dockerVersions: "all"),
  64. all_py34: runTests(pythonVersions: "py34", dockerVersions: "all"),
  65. )
  66. }
  67. parallel(
  68. failFast: false,
  69. docs: checkDocs,
  70. test: buildAndTest
  71. )