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.

Jenkinsfile 7.5KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. node("${NodeName}") {
  2. def PlatformTarget = params.containsKey("PlatformTarget") ? params.PlatformTarget : "x64"
  3. def MetaBranch = params.containsKey("MetaBranch") ? params.MetaBranch : "master"
  4. // Add some informations about the build
  5. manager.addShortText("${params.BuildType}", "red", "white", "0px", "white")
  6. manager.addShortText("${NodeName}", "blue", "white", "0px", "white")
  7. manager.addShortText("${PlatformTarget}", "green", "white", "0px", "white")
  8. OpenViBEVersion = "x.x.x"
  9. def BuildOptions = [
  10. "Release" : "--release",
  11. "Debug" : "--debug"
  12. ]
  13. def BuildOption = BuildOptions[BuildType]
  14. url_sdk = "https://gitlab.inria.fr/openvibe/sdk.git"
  15. url_designer = "https://gitlab.inria.fr/openvibe/designer.git"
  16. if(isUnix()) {
  17. build_dir = "${WORKSPACE}/build"
  18. dist_dir = "${WORKSPACE}/dist"
  19. dependencies_dir = "/builds/dependencies"
  20. dependencies_base = "/builds/dependencies"
  21. } else {
  22. build_dir = "${WORKSPACE}\\build"
  23. dist_dir = "${WORKSPACE}\\dist"
  24. if( "${PlatformTarget}" == "x64") {
  25. dependencies_dir = "c:\\builds\\dependencies_x64"
  26. } else {
  27. dependencies_dir = "c:\\builds\\dependencies"
  28. }
  29. dependencies_base = "c:\\builds\\dependencies"
  30. }
  31. user_data_subdir = "openvibe-${OpenViBEVersion}"
  32. git url: 'https://gitlab.inria.fr/openvibe/meta.git', branch: "${MetaBranch}"
  33. shortCommitMeta = get_short_commit()
  34. manager.addShortText("Meta : ${MetaBranch} (${shortCommitMeta})", "black", "white", "0px", "white")
  35. dir("build") {
  36. deleteDir()
  37. }
  38. dir("dist") {
  39. deleteDir()
  40. }
  41. // In order to update the dependencies, we need to pull all repositories first
  42. stage('Checkout') {
  43. dir("sdk") {
  44. git url: "${url_sdk}", branch: "${params.SDKBranch}"
  45. shortCommitSDK = get_short_commit()
  46. manager.addShortText("SDK : ${params.SDKBranch} (${shortCommitSDK})", "black", "white", "0px", "white")
  47. }
  48. dir("designer") {
  49. git url: "${url_designer}", branch: "${params.DesignerBranch}"
  50. shortCommitDesigner = get_short_commit()
  51. manager.addShortText("Designer : ${params.DesignerBranch} (${shortCommitDesigner})", "black", "white", "0px", "white")
  52. }
  53. dir("extras") {
  54. git url: 'https://gitlab.inria.fr/openvibe/extras.git', branch: "${params.ExtrasBranch}"
  55. shortCommitExtras = get_short_commit()
  56. manager.addShortText("Extras : ${params.ExtrasBranch} (${shortCommitExtras})", "black", "white", "0px", "white")
  57. if(isUnix()) {
  58. sh "git submodule update --init --recursive"
  59. } else {
  60. bat "git submodule update --init --recursive"
  61. }
  62. }
  63. }
  64. stage('Update dependencies') {
  65. if(isUnix()) {
  66. manager.addShortText("Not updating dependencies on Linux", "black", "white", "0px", "white")
  67. } else {
  68. bat "install_dependencies.cmd --dependencies-dir ${dependencies_base} --platform-target ${PlatformTarget}"
  69. }
  70. }
  71. stage('Build SDK') {
  72. dir("sdk") {
  73. dir ("scripts") {
  74. if(isUnix()) {
  75. sh "./unix-build --build-type ${params.BuildType} --build-dir ${build_dir}/sdk-${params.BuildType} --install-dir ${dist_dir}/sdk-${params.BuildType} --dependencies-dir ${dependencies_dir} --userdata-subdir ${user_data_subdir} --build-unit --build-validation --test-data-dir ${dependencies_dir}/test-input"
  76. } else {
  77. bat "windows-build.cmd --no-pause ${BuildOption} --build-dir ${build_dir}\\sdk-${params.BuildType} --install-dir ${dist_dir}\\sdk-${params.BuildType}-${PlatformTarget} --dependencies-dir ${dependencies_dir} --userdata-subdir ${user_data_subdir} --platform-target ${PlatformTarget} --build-unit --build-validation --test-data-dir ${dependencies_dir}\\test-input"
  78. }
  79. }
  80. }
  81. }
  82. stage('Tests SDK') {
  83. dir ("build/sdk-${params.BuildType}") {
  84. dir("unit-test/Testing") {
  85. deleteDir()
  86. }
  87. dir("validation-test/Testing") {
  88. deleteDir()
  89. }
  90. if(isUnix()) {
  91. sh './ctest-launcher.sh -T Test ; exit 0'
  92. } else {
  93. withEnv(["PATH+OV=${dist_dir}\\sdk-${params.BuildType}-${PlatformTarget}\\bin"]) {
  94. bat 'ctest-launcher.cmd -T Test -E uoTimeTest ; exit 0'
  95. }
  96. }
  97. step([$class: 'XUnitBuilder',
  98. thresholds: [[$class: 'FailedThreshold', unstableThreshold: '0']],
  99. tools: [[$class: 'CTestType', pattern: "unit-test/Testing/*/Test.xml"],
  100. [$class: 'CTestType', pattern: "validation-test/Testing/*/Test.xml"],]
  101. ])
  102. }
  103. }
  104. stage('Build Designer') {
  105. dir("designer") {
  106. dir ("scripts") {
  107. if(isUnix()) {
  108. sh "./unix-build --build-type=${params.BuildType} --build-dir=${build_dir}/designer-${params.BuildType} --install-dir=${dist_dir}/designer-${params.BuildType} --sdk=${dist_dir}/sdk-${params.BuildType}"
  109. } else {
  110. bat "windows-build.cmd --no-pause ${BuildOption} --build-dir ${build_dir}\\designer-${params.BuildType} --install-dir ${dist_dir}\\designer-${params.BuildType}-${PlatformTarget} --sdk ${dist_dir}\\sdk-${params.BuildType}-${PlatformTarget} --dependencies-dir ${dependencies_dir} --userdata-subdir ${user_data_subdir} --platform-target ${PlatformTarget}"
  111. }
  112. }
  113. }
  114. }
  115. stage('Build Extras') {
  116. dir("extras") {
  117. dir ("scripts") {
  118. if(isUnix()) {
  119. sh "./linux-build ${BuildOption} --build-dir ${build_dir}/extras-${params.BuildType} --install-dir ${dist_dir}/extras-${params.BuildType} --sdk ${dist_dir}/sdk-${params.BuildType} --designer ${dist_dir}/designer-${params.BuildType} --dependencies-dir ${dependencies_dir} --userdata-subdir ${user_data_subdir}"
  120. } else {
  121. bat "windows-build.cmd --no-pause ${BuildOption} --build-dir ${build_dir}\\extras-${params.BuildType} --install-dir ${dist_dir}\\extras-${params.BuildType}-${PlatformTarget} --sdk ${dist_dir}\\sdk-${params.BuildType}-${PlatformTarget} --designer ${dist_dir}\\designer-${params.BuildType}-${PlatformTarget} --dependencies-dir ${dependencies_dir} --userdata-subdir ${user_data_subdir} --platform-target ${PlatformTarget}"
  122. }
  123. }
  124. }
  125. }
  126. stage('Tests Extras') {
  127. dir ("build/extras-${params.BuildType}") {
  128. dir("Testing") {
  129. deleteDir()
  130. }
  131. if(isUnix()) {
  132. wrap([$class: 'Xvfb']) {
  133. sh "ctest -T Test ; exit 0"
  134. }
  135. } else {
  136. withEnv(["PATH+CTEST=${dependencies_dir}\\cmake\\bin",
  137. "PATH+OV=${dist_dir}\\extras-${params.BuildType}-${PlatformTarget}"]) {
  138. bat "ctest -T Test ; exit 0"
  139. }
  140. }
  141. step([$class: 'XUnitBuilder',
  142. thresholds: [[$class: 'FailedThreshold', unstableThreshold: '0']],
  143. tools: [[$class: 'CTestType', pattern: "Testing/*/Test.xml"],]])
  144. }
  145. }
  146. stage('Create Archive') {
  147. if(isUnix()) {
  148. dir("package") {
  149. deleteDir()
  150. sh "tar --owner 0 --group 0 --transform s,^\\.,openvibe-${OpenViBEVersion}-src, --exclude \".git*\" --exclude build --exclude dependencies --exclude dist --exclude scripts/*.exe --exclude package --exclude \"*@tmp\" -cJvf openvibe-${OpenViBEVersion}-src.tar.xz ${WORKSPACE}"
  151. sh "md5sum openvibe-${OpenViBEVersion}-src.tar.xz >openvibe-${OpenViBEVersion}-src.md5"
  152. }
  153. } else {
  154. dir("package") {
  155. deleteDir()
  156. withEnv(["PATH+NSIS=${dependencies_dir}\\nsis_log_zip_access"]) {
  157. bat "makensis /DDEPENDENCIES_DIR=${dependencies_dir} /DOUTFILE=${WORKSPACE}\\package\\openvibe-${OpenViBEVersion}-${PlatformTarget}-setup.exe ${WORKSPACE}\\extras\\scripts\\windows-openvibe-x.x.x-setup-${PlatformTarget}.nsi"
  158. }
  159. withEnv(["PATH+CMAKE=${dependencies_dir}\\cmake\\bin"]) {
  160. bat "@cmake -E md5sum openvibe-${OpenViBEVersion}-${PlatformTarget}-setup.exe >openvibe-${OpenViBEVersion}-${PlatformTarget}-setup.md5"
  161. }
  162. }
  163. }
  164. }
  165. }
  166. def get_short_commit() {
  167. if(isUnix()) {
  168. sh(returnStdout: true, script: "git log -n 1 --pretty=format:'%h'").trim()
  169. } else {
  170. bat(returnStdout: true, script: "@git log -n 1 --pretty=format:\'%%h\'").trim()
  171. }
  172. }