[ci] Use dl.internalx.com when building on private Jenkins
[mono-project.git] / scripts / ci / pipeline / osx-package.groovy
blob644fc826c3f9ed662b2e9824fb9813f7b8ed2d60
1 def isPrivate = (env.JENKINS_URL ==~ /.*jenkins\.internalx\.com.*/ ? true : false)
2 def isPr = (env.ghprbPullId && !env.ghprbPullId.empty ? true : false)
3 def monoBranch = (isPr ? "pr" : env.BRANCH_NAME)
4 def isReleaseJob = (!isPr && monoBranch ==~ /201\d-\d\d/) // check if we're on a 2017-xx branch, i.e. release
5 def jobName = (isPr ? "build-package-osx-mono-pullrequest" : isPrivate ? "build-package-osx-mono-private" : "build-package-osx-mono")
6 def windowsJobName = (isPr ? "build-package-win-mono-pullrequest" : isPrivate ? "build-package-win-mono-private/${monoBranch}" : "build-package-win-mono/${monoBranch}")
7 def isWindowsPrBuild = (isPr && env.ghprbCommentBody.contains("@monojenkins build pkg and msi"))
8 def packageFileName = null
9 def commitHash = null
10 def utils = null
11 // compression is incompatible with JEP-210 right now
12 properties([ /* compressBuildLog() */ ])
14 node ("mono-package") {
15 ws ("workspace/${jobName}/${monoBranch}") {
16 timestamps {
17 stage('Checkout') {
18 // clone and checkout repo
19 checkout scm
21 // remove old stuff
22 sh 'git clean -xdff'
24 // get current commit sha
25 commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
26 currentBuild.displayName = "${commitHash.substring(0,7)}"
28 utils = load "scripts/ci/pipeline/utils.groovy"
30 try {
31 stage('Build') {
32 utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'PENDING', 'Building...')
34 // workaround for libtiff issue
35 sh 'make -C external/bockbuild/builds/tiff-4.0.8-x86 clean || true'
36 sh 'make -C external/bockbuild/builds/tiff-4.0.8-x64 clean || true'
38 // build the .pkg
39 timeout (time: 420, unit: 'MINUTES') {
40 withEnv (["MONO_BRANCH=${isPr ? '' : monoBranch}", "MONO_BUILD_REVISION=${commitHash}"]) {
41 sshagent (credentials: ['mono-extensions-ssh']) {
42 sh "external/bockbuild/bb MacSDKRelease --arch darwin-universal --verbose --package ${isReleaseJob ? '--release' : ''}"
47 // move .pkg to the workspace root
48 sh 'mv packaging/MacSDKRelease/MonoFramework-MDK-*.pkg .'
49 packageFileName = findFiles (glob: "MonoFramework-MDK-*.pkg")[0].name
51 stage('Upload .pkg to Azure') {
52 azureUpload(storageCredentialId: (isPrivate ? "bc6a99d18d7d9ca3f6bf6b19e364d564" : "fbd29020e8166fbede5518e038544343"),
53 storageType: "blobstorage",
54 containerName: "${jobName}",
55 virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/",
56 filesPath: "${packageFileName}",
57 allowAnonymousAccess: (isPrivate ? false : true),
58 pubAccessible: (isPrivate ? false : true),
59 doNotWaitForPreviousBuild: true,
60 uploadArtifactsOnlyIfSuccessful: true)
63 if (isReleaseJob) {
64 stage("Signing") {
65 timeout(time: 30, unit: 'MINUTES') {
66 // waits until the signing job posts completion signal to this pipeline input
67 input id: 'FinishedSigning', message: 'Waiting for signing to finish...', submitter: 'monojenkins'
68 echo "Signing done."
72 else {
73 echo "Not a release job, skipping signing."
76 def downloadHost = (isPrivate ? "dl.internalx.com" : "xamjenkinsartifact.azureedge.net")
77 def packageUrl = "https://${downloadHost}/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}"
78 currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrl}/${packageFileName}\">${packageFileName}</a></h2><hr/>"
80 if (isReleaseJob) { utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'artifacts.json', "${packageUrl}/artifacts.json", 'SUCCESS', '') }
81 utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', "${packageUrl}/${packageFileName}", 'SUCCESS', packageFileName)
83 catch (Exception e) {
84 utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'FAILURE', "Build failed.")
85 throw e
91 if (isPrivate) {
92 // skip Windows build on private jobs for now
93 return
96 if (!isPr || isWindowsPrBuild) {
97 def parameters = [[$class: 'StringParameterValue', name: 'sha1', value: commitHash]]
99 if (isWindowsPrBuild) {
100 parameters += [$class: 'StringParameterValue', name: 'ghprbPullId', value: env.ghprbPullId]
101 parameters += [$class: 'StringParameterValue', name: 'ghprbActualCommit', value: env.ghprbActualCommit]
104 // trigger the Windows build
105 build(job: "${windowsJobName}", wait: false, parameters: parameters)