win-package.groovy 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. isPr = (env.ghprbPullId && !env.ghprbPullId.empty ? true : false)
  2. monoBranch = (isPr ? "pr" : env.BRANCH_NAME)
  3. isReleaseJob = (!isPr && monoBranch ==~ /20\d\d-\d\d/) // check if we're on a 2017-xx branch, i.e. release
  4. jobName = (isPr ? "build-package-win-mono-pullrequest" : "build-package-win-mono")
  5. macJobName = (isPr ? "build-package-osx-mono-pullrequest" : "build-package-osx-mono/${monoBranch}")
  6. packageFileNameX86 = null
  7. packageFileNameX64 = null
  8. commitHash = null
  9. utils = null
  10. // compression is incompatible with JEP-210 right now
  11. properties([ /* compressBuildLog() */])
  12. try {
  13. timestamps {
  14. node("w64") {
  15. ws("workspace/${jobName}/${monoBranch}") {
  16. stage('Checkout') {
  17. echo "Running on ${env.NODE_NAME}"
  18. // clone and checkout repo
  19. checkout scm
  20. // we need to reset to the commit sha passed to us by the upstream Mac build
  21. sh (script: "git reset --hard ${env.sha1} && git submodule update --recursive")
  22. // get current commit sha
  23. commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
  24. currentBuild.displayName = "${commitHash.substring(0,7)}"
  25. utils = load "scripts/ci/pipeline/utils.groovy"
  26. }
  27. stage('Download Mac .pkg from Azure') {
  28. azureDownload(storageCredentialId: "fbd29020e8166fbede5518e038544343",
  29. downloadType: "project",
  30. buildSelector: upstream(),
  31. projectName: "${macJobName}",
  32. flattenDirectories: true,
  33. includeFilesPattern: "**/*.pkg")
  34. }
  35. stage('Build') {
  36. // build the .msi
  37. timeout (time: 420, unit: 'MINUTES') {
  38. def macPackageName = sh (script: "ls MonoFramework-MDK-*.pkg", returnStdout: true).trim()
  39. def macPackageNameAbs = sh (script: "realpath ${macPackageName}", returnStdout: true).trim()
  40. def fourPartVersion = sh (script: "echo ${macPackageName} | sed 's#.*MDK-##; s#\\.macos10.*##; s#.*-dirty-##' | cut -f1-4 -d'.'", returnStdout: true).trim()
  41. def gtksharpVersion = sh (script: "sed -n 's/GTKSHARP_VERSION=\\(.*\\)/\\1/p' packaging/Windows/defs/gtksharp", returnStdout: true).trim()
  42. sh "sed -i \"s/\\(GTKSHARP_VERSION=\\).*/\\1${gtksharpVersion}/\" packaging/Windows/resources/build.bat"
  43. sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build.bat"
  44. sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build64.bat"
  45. sh "sed -i \"s/\\(echo Mono version \\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/bat/setmonopath.bat"
  46. withEnv (["PATH+TOOLS=/usr/bin:/usr/local/bin:/cygdrive/c/Program Files (x86)/Mono/bin", "mdk=${macPackageNameAbs}"]) {
  47. // build x86 MSI
  48. dir ('packaging/Windows') { sh "./mono-MDK-windows" }
  49. sh "git clean -xdff --exclude 'mono-*.msi' --exclude ${macPackageName}"
  50. sh "git submodule foreach git clean -xdff"
  51. // build x64 MSI
  52. dir ('packaging/Windows') { sh "./mono-MDK-windows-x64" }
  53. }
  54. }
  55. // move .msi files to the workspace root
  56. sh 'mv packaging/Windows/resources/bin/Release/mono-*.msi .'
  57. packageFileNameX86 = findFiles (glob: "mono-*-win32-0.msi")[0].name
  58. packageFileNameX64 = findFiles (glob: "mono-*-x64-0.msi")[0].name
  59. }
  60. stage('Upload .msi to Azure') {
  61. azureUpload(storageCredentialId: "fbd29020e8166fbede5518e038544343",
  62. storageType: "blobstorage",
  63. containerName: "${jobName}",
  64. virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/unsigned/",
  65. filesPath: "${packageFileNameX86},${packageFileNameX64}",
  66. allowAnonymousAccess: true,
  67. pubAccessible: true,
  68. doNotWaitForPreviousBuild: true,
  69. uploadArtifactsOnlyIfSuccessful: true)
  70. }
  71. sh 'git clean -xdff'
  72. }
  73. }
  74. def packageUrlX86 = "https://xamjenkinsartifact.blob.core.windows.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/unsigned/${packageFileNameX86}"
  75. def packageUrlX64 = "https://xamjenkinsartifact.blob.core.windows.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/unsigned/${packageFileNameX64}";
  76. currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrlX86}\">${packageFileNameX86}</a> -- <a href=\"${packageUrlX64}\">${packageFileNameX64}</a></h2><hr/>"
  77. }
  78. }
  79. catch (Exception e) {
  80. utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', env.BUILD_URL, 'FAILURE', "Build failed.")
  81. utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', env.BUILD_URL, 'FAILURE', "Build failed.")
  82. throw e
  83. }