osx-package.groovy 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. isPrivate = false
  2. isPr = (env.ghprbPullId && !env.ghprbPullId.empty ? true : false)
  3. monoBranch = (isPr ? "pr" : env.BRANCH_NAME)
  4. isReleaseJob = (!isPr && monoBranch ==~ /20\d\d-\d\d/) // check if we're on a 2017-xx branch, i.e. release
  5. jobName = (isPr ? "build-package-osx-mono-pullrequest" : isPrivate ? "build-package-osx-mono-private" : "build-package-osx-mono")
  6. windowsJobName = (isPr ? "build-package-win-mono-pullrequest" : isPrivate ? "build-package-win-mono-private/${monoBranch}" : "build-package-win-mono/${monoBranch}")
  7. isWindowsPrBuild = (isPr && env.ghprbCommentBody.contains("@monojenkins build pkg and msi"))
  8. packageFileName = null
  9. commitHash = null
  10. utils = null
  11. if (monoBranch == 'main') {
  12. properties([ /* compressBuildLog() */ // compression is incompatible with JEP-210 right now
  13. disableConcurrentBuilds()
  14. ])
  15. }
  16. try {
  17. timestamps {
  18. node(isPr ? "mono-package-pr" : "mono-package") {
  19. ws("workspace/${jobName}/${monoBranch}") {
  20. stage('Checkout') {
  21. echo "Running on ${env.NODE_NAME}"
  22. // clone and checkout repo
  23. checkout scm
  24. // remove old stuff
  25. sh 'git clean -xdff'
  26. // get current commit sha
  27. commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
  28. currentBuild.displayName = "${commitHash.substring(0,7)}"
  29. utils = load "scripts/ci/pipeline/utils.groovy"
  30. }
  31. stage('Build') {
  32. // build the .pkg
  33. timeout (time: 420, unit: 'MINUTES') {
  34. withEnv (["MONO_BRANCH=${isPr ? '' : monoBranch}", "MONO_BUILD_REVISION=${commitHash}"]) {
  35. sshagent (credentials: ['mono-extensions-ssh']) {
  36. sh "external/bockbuild/bb MacSDKRelease --arch darwin-universal --verbose --package ${isReleaseJob ? '--release' : ''}"
  37. }
  38. }
  39. }
  40. // move .pkg to the workspace root
  41. sh 'mv packaging/MacSDKRelease/MonoFramework-MDK-*.pkg .'
  42. packageFileName = findFiles (glob: "MonoFramework-MDK-*.pkg")[0].name
  43. // move mac-entitlements.plist to the workspace root
  44. sh 'mv mono/mini/mac-entitlements.plist .'
  45. }
  46. stage('Upload .pkg to Azure') {
  47. azureUpload(storageCredentialId: (isPrivate ? "bc6a99d18d7d9ca3f6bf6b19e364d564" : "fbd29020e8166fbede5518e038544343"),
  48. storageType: "blobstorage",
  49. containerName: "${jobName}",
  50. virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/unsigned/",
  51. filesPath: "${packageFileName},mac-entitlements.plist",
  52. allowAnonymousAccess: (isPrivate ? false : true),
  53. pubAccessible: (isPrivate ? false : true),
  54. doNotWaitForPreviousBuild: true,
  55. uploadArtifactsOnlyIfSuccessful: true)
  56. }
  57. sh 'git clean -xdff'
  58. }
  59. }
  60. def downloadHost = (isPrivate ? "dl.internalx.com" : "xamjenkinsartifact.blob.core.windows.net")
  61. def packageUrl = "https://${downloadHost}/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/unsigned"
  62. currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrl}/${packageFileName}\">${packageFileName}</a></h2><hr/>"
  63. }
  64. }
  65. catch (Exception e) {
  66. utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'FAILURE', "Build failed.")
  67. throw e
  68. }
  69. if (isPrivate) {
  70. // skip Windows build on private jobs for now
  71. return
  72. }
  73. if (!isPr || isWindowsPrBuild) {
  74. def parameters = [[$class: 'StringParameterValue', name: 'sha1', value: commitHash]]
  75. if (isWindowsPrBuild) {
  76. parameters += [$class: 'StringParameterValue', name: 'ghprbPullId', value: env.ghprbPullId]
  77. parameters += [$class: 'StringParameterValue', name: 'ghprbActualCommit', value: env.ghprbActualCommit]
  78. }
  79. // trigger the Windows build
  80. build(job: "${windowsJobName}", wait: false, parameters: parameters)
  81. }