2
0
Эх сурвалжийг харах

[ci] Report pending/failed status on GitHub for pkg/msi

Alexander Köplinger 7 жил өмнө
parent
commit
0bfda265b7

+ 62 - 57
scripts/ci/pipeline/osx-package.groovy

@@ -5,6 +5,7 @@ def jobName = (isPr ? "build-package-osx-mono-pullrequest" : "build-package-osx-
 def windowsJobName = "build-package-win-mono"
 def windowsJobName = "build-package-win-mono"
 def packageFileName = null
 def packageFileName = null
 def commitHash = null
 def commitHash = null
+def utils = null
 
 
 node ("osx-amd64") {
 node ("osx-amd64") {
     ws ("workspace/${jobName}/${monoBranch}") {
     ws ("workspace/${jobName}/${monoBranch}") {
@@ -19,76 +20,80 @@ node ("osx-amd64") {
                 // get current commit sha
                 // get current commit sha
                 commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
                 commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
                 currentBuild.displayName = "${commitHash.substring(0,7)}"
                 currentBuild.displayName = "${commitHash.substring(0,7)}"
+
+                utils = load "scripts/ci/pipeline/utils.groovy"
             }
             }
-            stage('Build') {
+            try {
+                stage('Build') {
+                    utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'PENDING', 'Building...')
 
 
-                // install openssl for .net core (remove once msbuild uses a 2.x version which doesn't rely on openssl)
-                sh 'brew update && brew install openssl'
-                sh 'mkdir -p /usr/local/lib'
-                sh 'rm /usr/local/lib/libcrypto.1.0.0.dylib || true'
-                sh 'rm /usr/local/lib/libssl.1.0.0.dylib || true'
-                sh 'ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/'
-                sh 'ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/'
+                    // install openssl for .net core (remove once msbuild uses a 2.x version which doesn't rely on openssl)
+                    sh 'brew update && brew install openssl'
+                    sh 'mkdir -p /usr/local/lib'
+                    sh 'rm /usr/local/lib/libcrypto.1.0.0.dylib || true'
+                    sh 'rm /usr/local/lib/libssl.1.0.0.dylib || true'
+                    sh 'ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/'
+                    sh 'ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/'
 
 
 
 
-                // workaround for libtiff issue
-                sh 'make -C external/bockbuild/builds/tiff-4.0.8-x86 clean || true'
-                sh 'make -C external/bockbuild/builds/tiff-4.0.8-x64 clean || true'
+                    // workaround for libtiff issue
+                    sh 'make -C external/bockbuild/builds/tiff-4.0.8-x86 clean || true'
+                    sh 'make -C external/bockbuild/builds/tiff-4.0.8-x64 clean || true'
 
 
-                // build the .pkg
-                timeout (time: 420, unit: 'MINUTES') {
-                    withEnv (["MONO_BRANCH=${isPr ? '' : monoBranch}", "MONO_BUILD_REVISION=${commitHash}"]) {
-                        sshagent (credentials: ['mono-extensions-ssh']) {
-                            sh "external/bockbuild/bb MacSDKRelease --arch darwin-universal --verbose --package ${isReleaseJob ? '--release' : ''}"
+                    // build the .pkg
+                    timeout (time: 420, unit: 'MINUTES') {
+                        withEnv (["MONO_BRANCH=${isPr ? '' : monoBranch}", "MONO_BUILD_REVISION=${commitHash}"]) {
+                            sshagent (credentials: ['mono-extensions-ssh']) {
+                                sh "external/bockbuild/bb MacSDKRelease --arch darwin-universal --verbose --package ${isReleaseJob ? '--release' : ''}"
+                            }
                         }
                         }
                     }
                     }
-                }
 
 
-                // move .pkg to the workspace root
-                sh 'mv packaging/MacSDKRelease/MonoFramework-MDK-*.pkg .'
-                packageFileName = findFiles (glob: "MonoFramework-MDK-*.pkg")[0]
-            }
-            stage('Upload .pkg to Azure') {
-                step([
-                    $class: 'WAStoragePublisher',
-                    allowAnonymousAccess: true,
-                    cleanUpContainer: false,
-                    cntPubAccess: true,
-                    containerName: "${jobName}",
-                    doNotFailIfArchivingReturnsNothing: false,
-                    doNotUploadIndividualFiles: false,
-                    doNotWaitForPreviousBuild: true,
-                    excludeFilesPath: '',
-                    filesPath: "${packageFileName}",
-                    storageAccName: 'credential for xamjenkinsartifact',
-                    storageCredentialId: 'fbd29020e8166fbede5518e038544343',
-                    uploadArtifactsOnlyIfSuccessful: true,
-                    uploadZips: false,
-                    virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/"
-                ])
-            }
+                    // move .pkg to the workspace root
+                    sh 'mv packaging/MacSDKRelease/MonoFramework-MDK-*.pkg .'
+                    packageFileName = findFiles (glob: "MonoFramework-MDK-*.pkg")[0]
+                }
+                stage('Upload .pkg to Azure') {
+                    step([
+                        $class: 'WAStoragePublisher',
+                        allowAnonymousAccess: true,
+                        cleanUpContainer: false,
+                        cntPubAccess: true,
+                        containerName: "${jobName}",
+                        doNotFailIfArchivingReturnsNothing: false,
+                        doNotUploadIndividualFiles: false,
+                        doNotWaitForPreviousBuild: true,
+                        excludeFilesPath: '',
+                        filesPath: "${packageFileName}",
+                        storageAccName: 'credential for xamjenkinsartifact',
+                        storageCredentialId: 'fbd29020e8166fbede5518e038544343',
+                        uploadArtifactsOnlyIfSuccessful: true,
+                        uploadZips: false,
+                        virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/"
+                    ])
+                }
 
 
-            if (isReleaseJob) {
-                stage("Signing") {
-                    timeout(time: 30, unit: 'MINUTES') {
-                        // waits until the signing job posts completion signal to this pipeline input
-                        input id: 'FinishedSigning', message: 'Waiting for signing to finish...', submitter: 'monojenkins'
-                        echo "Signing done."
+                if (isReleaseJob) {
+                    stage("Signing") {
+                        timeout(time: 30, unit: 'MINUTES') {
+                            // waits until the signing job posts completion signal to this pipeline input
+                            input id: 'FinishedSigning', message: 'Waiting for signing to finish...', submitter: 'monojenkins'
+                            echo "Signing done."
+                        }
                     }
                     }
                 }
                 }
+                else {
+                    echo "Not a release job, skipping signing."
+                }
+
+                def packageUrl = "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileName}"
+                currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrl}\">${packageFileName}</a></h2><hr/>"
+                utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', packageUrl, 'SUCCESS', packageFileName)
             }
             }
-            else {
-                echo "Not a release job, skipping signing."
+            catch (Exception e) {
+                utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'FAILURE', "Build failed.")
+                throw e
             }
             }
-
-            currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileName}\">${packageFileName}</a></h2><hr/>"
-            step([
-                $class: 'GitHubCommitStatusSetter',
-                commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitHash],
-                contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: 'PKG-mono'],
-                statusBackrefSource: [$class: 'ManuallyEnteredBackrefSource', backref: "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileName}"],
-                statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', state: 'SUCCESS', message: "${packageFileName}"]]]
-            ])
         }
         }
     }
     }
 }
 }

+ 11 - 0
scripts/ci/pipeline/utils.groovy

@@ -0,0 +1,11 @@
+def reportGitHubStatus(commitHash, context, backref, statusResult, statusResultMessage) {
+    step([
+        $class: 'GitHubCommitStatusSetter',
+        commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitHash],
+        contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: context],
+        statusBackrefSource: [$class: 'ManuallyEnteredBackrefSource', backref: backref],
+        statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', state: statusResult, message: statusResultMessage]]]
+    ])
+}
+
+return this

+ 71 - 67
scripts/ci/pipeline/win-package.groovy

@@ -5,6 +5,7 @@ def macJobName = "build-package-osx-mono"
 def packageFileNameX86 = null
 def packageFileNameX86 = null
 def packageFileNameX64 = null
 def packageFileNameX64 = null
 def commitHash = null
 def commitHash = null
+def utils = null
 
 
 node ("w64") {
 node ("w64") {
     ws ("workspace/${jobName}/${monoBranch}") {
     ws ("workspace/${jobName}/${monoBranch}") {
@@ -16,6 +17,8 @@ node ("w64") {
                 // get current commit sha
                 // get current commit sha
                 commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
                 commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim()
                 currentBuild.displayName = "${commitHash.substring(0,7)}"
                 currentBuild.displayName = "${commitHash.substring(0,7)}"
+
+                utils = load "scripts/ci/pipeline/utils.groovy"
             }
             }
             stage('Download Mac .pkg from Azure') {
             stage('Download Mac .pkg from Azure') {
                 step([
                 step([
@@ -31,84 +34,85 @@ node ("w64") {
                     storageCredentialId: 'fbd29020e8166fbede5518e038544343'
                     storageCredentialId: 'fbd29020e8166fbede5518e038544343'
                 ])
                 ])
             }
             }
-            stage('Build') {
-                // build the .msi
-                timeout (time: 420, unit: 'MINUTES') {
-                    def macPackageName = sh (script: "ls MonoFramework-MDK-*.pkg", returnStdout: true).trim()
-                    def macPackageNameAbs = sh (script: "realpath ${macPackageName}", returnStdout: true).trim()
-                    def fourPartVersion =  sh (script: "echo ${macPackageName} | sed 's#.*MDK-##; s#\\.macos10.*##; s#.*-dirty-##' | cut -f1-4 -d'.'", returnStdout: true).trim()
-                    def gtksharpVersion = sh (script: "sed -n 's/GTKSHARP_VERSION=\\(.*\\)/\\1/p' packaging/Windows/defs/gtksharp", returnStdout: true).trim()
+            try {
+                stage('Build') {
+                    utils.reportGitHubStatus (commitHash, 'MSI-mono_x86', env.BUILD_URL, 'PENDING', 'Building...')
+                    utils.reportGitHubStatus (commitHash, 'MSI-mono_x64', env.BUILD_URL, 'PENDING', 'Building...')
+
+                    // build the .msi
+                    timeout (time: 420, unit: 'MINUTES') {
+                        def macPackageName = sh (script: "ls MonoFramework-MDK-*.pkg", returnStdout: true).trim()
+                        def macPackageNameAbs = sh (script: "realpath ${macPackageName}", returnStdout: true).trim()
+                        def fourPartVersion =  sh (script: "echo ${macPackageName} | sed 's#.*MDK-##; s#\\.macos10.*##; s#.*-dirty-##' | cut -f1-4 -d'.'", returnStdout: true).trim()
+                        def gtksharpVersion = sh (script: "sed -n 's/GTKSHARP_VERSION=\\(.*\\)/\\1/p' packaging/Windows/defs/gtksharp", returnStdout: true).trim()
 
 
-                    sh "sed -i \"s/\\(GTKSHARP_VERSION=\\).*/\\1${gtksharpVersion}/\" packaging/Windows/resources/build.bat"
-                    sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build.bat"
-                    sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build64.bat"
-                    sh "sed -i \"s/\\(echo Mono version \\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/bat/setmonopath.bat"
+                        sh "sed -i \"s/\\(GTKSHARP_VERSION=\\).*/\\1${gtksharpVersion}/\" packaging/Windows/resources/build.bat"
+                        sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build.bat"
+                        sh "sed -i \"s/\\(MONO_VERSION=\\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/build64.bat"
+                        sh "sed -i \"s/\\(echo Mono version \\).*/\\1${fourPartVersion}/\" packaging/Windows/resources/bat/setmonopath.bat"
 
 
-                    withEnv (["PATH+TOOLS=/usr/bin:/usr/local/bin:/cygdrive/c/Program Files (x86)/Mono/bin", "mdk=${macPackageNameAbs}"]) {
-                        // build x86 MSI
-                        dir ('packaging/Windows') { sh "./mono-MDK-windows" }
+                        withEnv (["PATH+TOOLS=/usr/bin:/usr/local/bin:/cygdrive/c/Program Files (x86)/Mono/bin", "mdk=${macPackageNameAbs}"]) {
+                            // build x86 MSI
+                            dir ('packaging/Windows') { sh "./mono-MDK-windows" }
 
 
-                        sh "git clean -xdff --exclude 'mono-*.msi' --exclude ${macPackageName}"
-                        sh "git submodule foreach git clean -xdff"
+                            sh "git clean -xdff --exclude 'mono-*.msi' --exclude ${macPackageName}"
+                            sh "git submodule foreach git clean -xdff"
 
 
-                        // build x64 MSI
-                        dir ('packaging/Windows') { sh "./mono-MDK-windows-x64" }
+                            // build x64 MSI
+                            dir ('packaging/Windows') { sh "./mono-MDK-windows-x64" }
+                        }
                     }
                     }
-                }
 
 
-                // move .msi files to the workspace root
-                sh 'mv packaging/Windows/resources/bin/Release/mono-*.msi .'
-                packageFileNameX86 = findFiles (glob: "mono-*-win32-0.msi")[0]
-                packageFileNameX64 = findFiles (glob: "mono-*-x64-0.msi")[0]
-            }
-            stage('Upload .msi to Azure') {
-                step([
-                    $class: 'WAStoragePublisher',
-                    allowAnonymousAccess: true,
-                    cleanUpContainer: false,
-                    cntPubAccess: true,
-                    containerName: "${jobName}",
-                    doNotFailIfArchivingReturnsNothing: false,
-                    doNotUploadIndividualFiles: false,
-                    doNotWaitForPreviousBuild: true,
-                    excludeFilesPath: '',
-                    filesPath: "${packageFileNameX86},${packageFileNameX64}",
-                    storageAccName: 'credential for xamjenkinsartifact',
-                    storageCredentialId: 'fbd29020e8166fbede5518e038544343',
-                    uploadArtifactsOnlyIfSuccessful: true,
-                    uploadZips: false,
-                    virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/"
-                ])
-            }
+                    // move .msi files to the workspace root
+                    sh 'mv packaging/Windows/resources/bin/Release/mono-*.msi .'
+                    packageFileNameX86 = findFiles (glob: "mono-*-win32-0.msi")[0]
+                    packageFileNameX64 = findFiles (glob: "mono-*-x64-0.msi")[0]
+                }
+                stage('Upload .msi to Azure') {
+                    step([
+                        $class: 'WAStoragePublisher',
+                        allowAnonymousAccess: true,
+                        cleanUpContainer: false,
+                        cntPubAccess: true,
+                        containerName: "${jobName}",
+                        doNotFailIfArchivingReturnsNothing: false,
+                        doNotUploadIndividualFiles: false,
+                        doNotWaitForPreviousBuild: true,
+                        excludeFilesPath: '',
+                        filesPath: "${packageFileNameX86},${packageFileNameX64}",
+                        storageAccName: 'credential for xamjenkinsartifact',
+                        storageCredentialId: 'fbd29020e8166fbede5518e038544343',
+                        uploadArtifactsOnlyIfSuccessful: true,
+                        uploadZips: false,
+                        virtualPath: "${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/"
+                    ])
+                }
 
 
-            if (isReleaseJob) {
-                stage("Signing") {
-                    timeout(time: 30, unit: 'MINUTES') {
-                        // waits until the signing job posts completion signal to this pipeline input
-                        input id: 'FinishedSigning', message: 'Waiting for signing to finish...', submitter: 'monojenkins'
-                        echo "Signing done."
+                if (isReleaseJob) {
+                    stage("Signing") {
+                        timeout(time: 30, unit: 'MINUTES') {
+                            // waits until the signing job posts completion signal to this pipeline input
+                            input id: 'FinishedSigning', message: 'Waiting for signing to finish...', submitter: 'monojenkins'
+                            echo "Signing done."
+                        }
                     }
                     }
                 }
                 }
+                else {
+                    echo "Not a release job, skipping signing."
+                }
+
+                def packageUrlX86 = "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX86}"
+                def packageUrlX64 = "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX64}";
+
+                currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrlX86}\">${packageFileNameX86}</a> -- <a href=\"${packageUrlX64}\">${packageFileNameX64}</a></h2><hr/>"
+                utils.reportGitHubStatus (commitHash, 'MSI-mono_x86', packageUrlX86, 'SUCCESS', packageFileNameX86)
+                utils.reportGitHubStatus (commitHash, 'MSI-mono_x64', packageUrlX64, 'SUCCESS', packageFileNameX64)
             }
             }
-            else {
-                echo "Not a release job, skipping signing."
+            catch (Exception e) {
+                utils.reportGitHubStatus (commitHash, 'MSI-mono_x86', env.BUILD_URL, 'FAILURE', "Build failed.")
+                utils.reportGitHubStatus (commitHash, 'MSI-mono_x64', env.BUILD_URL, 'FAILURE', "Build failed.")
+                throw e
             }
             }
-
-            currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX86}\">${packageFileNameX86}</a> -- <a href=\"https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX64}\">${packageFileNameX64}</a></h2><hr/>"
-            step([
-                $class: 'GitHubCommitStatusSetter',
-                commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitHash],
-                contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: 'MSI-mono_x86'],
-                statusBackrefSource: [$class: 'ManuallyEnteredBackrefSource', backref: "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX86}"],
-                statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', state: 'SUCCESS', message: "${packageFileNameX86}"]]]
-            ])
-            step([
-                $class: 'GitHubCommitStatusSetter',
-                commitShaSource: [$class: "ManuallyEnteredShaSource", sha: commitHash],
-                contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: 'MSI-mono_x64'],
-                statusBackrefSource: [$class: 'ManuallyEnteredBackrefSource', backref: "https://xamjenkinsartifact.azureedge.net/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}/${packageFileNameX64}"],
-                statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[$class: 'AnyBuildResult', state: 'SUCCESS', message: "${packageFileNameX64}"]]]
-            ])
         }
         }
     }
     }
 }
 }