Jenkinsfile 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. parallel_nodes(['linux && cura', 'windows && cura'])
  2. {
  3. timeout(time: 2, unit: "HOURS")
  4. {
  5. // Prepare building
  6. stage('Prepare')
  7. {
  8. // Ensure we start with a clean build directory.
  9. step([$class: 'WsCleanup'])
  10. // Checkout whatever sources are linked to this pipeline.
  11. checkout scm
  12. }
  13. // If any error occurs during building, we want to catch it and continue with the "finale" stage.
  14. catchError
  15. {
  16. // Building and testing should happen in a subdirectory.
  17. dir('build')
  18. {
  19. // Perform the "build". Since Uranium is Python code, this basically only ensures CMake is setup.
  20. stage('Build')
  21. {
  22. def branch = env.BRANCH_NAME
  23. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}"))
  24. {
  25. branch = "master"
  26. }
  27. // Ensure CMake is setup. Note that since this is Python code we do not really "build" it.
  28. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  29. cmake("..", "-DCMAKE_PREFIX_PATH=\"${env.CURA_ENVIRONMENT_PATH}/${branch}\" -DCMAKE_BUILD_TYPE=Release -DURANIUM_DIR=\"${uranium_dir}\"")
  30. }
  31. // Try and run the unit tests. If this stage fails, we consider the build to be "unstable".
  32. stage('Unit Test')
  33. {
  34. if (isUnix())
  35. {
  36. // For Linux to show everything
  37. def branch = env.BRANCH_NAME
  38. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}"))
  39. {
  40. branch = "master"
  41. }
  42. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  43. try {
  44. sh """
  45. cd ..
  46. export PYTHONPATH=.:"${uranium_dir}"
  47. ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/pytest -x --verbose --full-trace --capture=no ./tests
  48. """
  49. } catch(e)
  50. {
  51. currentBuild.result = "UNSTABLE"
  52. }
  53. }
  54. else
  55. {
  56. // For Windows
  57. try
  58. {
  59. // This also does code style checks.
  60. bat 'ctest -V'
  61. } catch(e)
  62. {
  63. currentBuild.result = "UNSTABLE"
  64. }
  65. }
  66. }
  67. stage('Code Style')
  68. {
  69. if (isUnix())
  70. {
  71. // For Linux to show everything.
  72. // CMake also runs this test, but if it fails then the test just shows "failed" without details of what exactly failed.
  73. def branch = env.BRANCH_NAME
  74. if(!fileExists("${env.CURA_ENVIRONMENT_PATH}/${branch}"))
  75. {
  76. branch = "master"
  77. }
  78. def uranium_dir = get_workspace_dir("Ultimaker/Uranium/${branch}")
  79. try
  80. {
  81. sh """
  82. cd ..
  83. export PYTHONPATH=.:"${uranium_dir}"
  84. ${env.CURA_ENVIRONMENT_PATH}/${branch}/bin/python3 run_mypy.py
  85. """
  86. }
  87. catch(e)
  88. {
  89. currentBuild.result = "UNSTABLE"
  90. }
  91. }
  92. }
  93. }
  94. }
  95. // Perform any post-build actions like notification and publishing of unit tests.
  96. stage('Finalize')
  97. {
  98. // Publish the test results to Jenkins.
  99. junit allowEmptyResults: true, testResults: 'build/junit*.xml'
  100. notify_build_result(env.CURA_EMAIL_RECIPIENTS, '#cura-dev', ['master', '2.'])
  101. }
  102. }
  103. }