Jenkinsfile 2.0 KB

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