diff options
author | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-07-17 11:57:09 +0300 |
---|---|---|
committer | Alexander Köplinger <alex.koeplinger@outlook.com> | 2019-07-17 11:57:38 +0300 |
commit | d732cef5fc740cdb88e50d078f634202d140e6a9 (patch) | |
tree | a5036899adfb086201ac40fbfb97dde47ba42afc /scripts | |
parent | 3a075b0b1e98f2ab014cfcb54de0e6c46eec565f (diff) |
[ci] Remove separate utils.groovy file
For some reason when using a separate file and loading the function
from there Jenkins still requires us to have a node() context when
calling the function which is not what we want.
(cherry picked from commit d410e07d8bb969532fc910f1d6779930e00640a2)
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/ci/pipeline/osx-package.groovy | 21 | ||||
-rw-r--r-- | scripts/ci/pipeline/sdks-archive.groovy | 19 | ||||
-rw-r--r-- | scripts/ci/pipeline/utils.groovy | 11 | ||||
-rw-r--r-- | scripts/ci/pipeline/win-package.groovy | 25 |
4 files changed, 43 insertions, 33 deletions
diff --git a/scripts/ci/pipeline/osx-package.groovy b/scripts/ci/pipeline/osx-package.groovy index b34b5f4d2ad..3a2eab86b4f 100644 --- a/scripts/ci/pipeline/osx-package.groovy +++ b/scripts/ci/pipeline/osx-package.groovy @@ -7,7 +7,6 @@ def windowsJobName = (isPr ? "build-package-win-mono-pullrequest" : isPrivate ? def isWindowsPrBuild = (isPr && env.ghprbCommentBody.contains("@monojenkins build pkg and msi")) def packageFileName = null def commitHash = null -def utils = null // compression is incompatible with JEP-210 right now properties([ /* compressBuildLog() */ ]) @@ -27,12 +26,10 @@ try { // get current commit sha commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim() currentBuild.displayName = "${commitHash.substring(0,7)}" - - utils = load "scripts/ci/pipeline/utils.groovy" } stage('Build') { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'PENDING', 'Building...') + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'PENDING', 'Building...') // build the .pkg timeout (time: 420, unit: 'MINUTES') { @@ -82,12 +79,12 @@ try { def packageUrl = "https://${downloadHost}/${jobName}/${monoBranch}/${env.BUILD_NUMBER}/${commitHash}" currentBuild.description = "<hr/><h2>DOWNLOAD: <a href=\"${packageUrl}/${packageFileName}\">${packageFileName}</a></h2><hr/>" - if (isReleaseJob) { utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'artifacts.json', "${packageUrl}/artifacts.json", 'SUCCESS', '') } - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', "${packageUrl}/${packageFileName}", 'SUCCESS', packageFileName) + if (isReleaseJob) { reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'artifacts.json', "${packageUrl}/artifacts.json", 'SUCCESS', '') } + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', "${packageUrl}/${packageFileName}", 'SUCCESS', packageFileName) } } catch (Exception e) { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'FAILURE', "Build failed.") + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'PKG-mono', env.BUILD_URL, 'FAILURE', "Build failed.") throw e } @@ -107,3 +104,13 @@ if (!isPr || isWindowsPrBuild) { // trigger the Windows build build(job: "${windowsJobName}", wait: false, parameters: parameters) } + +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]]] + ]) +} diff --git a/scripts/ci/pipeline/sdks-archive.groovy b/scripts/ci/pipeline/sdks-archive.groovy index ae00ebc3942..25c6cf2181d 100644 --- a/scripts/ci/pipeline/sdks-archive.groovy +++ b/scripts/ci/pipeline/sdks-archive.groovy @@ -60,13 +60,22 @@ parallel ( } ) +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]]] + ]) +} + def archive (product, configuration, platform, chrootname = "", chrootadditionalpackages = "", chrootBindMounts = "") { def isPr = (env.ghprbPullId && !env.ghprbPullId.empty ? true : false) def monoBranch = (isPr ? "pr" : env.BRANCH_NAME) def jobName = (isPr ? "archive-mono-pullrequest" : "archive-mono") def packageFileName = null def commitHash = null - def utils = null ws ("workspace/${jobName}/${monoBranch}/${product}/${configuration}") { timestamps { @@ -76,8 +85,6 @@ def archive (product, configuration, platform, chrootname = "", chrootadditional // clone and checkout repo checkout scm - utils = load "scripts/ci/pipeline/utils.groovy" - // remove old stuff sh 'git reset --hard HEAD' // homebrew Git 2.22.0 misparses the submodule command and passes arguments like --hard and -xdff @@ -93,7 +100,7 @@ def archive (product, configuration, platform, chrootname = "", chrootadditional } try { stage('Build') { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", env.BUILD_URL, 'PENDING', 'Building...') + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", env.BUILD_URL, 'PENDING', 'Building...') // build the Archive timeout (time: 300, unit: 'MINUTES') { @@ -128,10 +135,10 @@ def archive (product, configuration, platform, chrootname = "", chrootadditional uploadArtifactsOnlyIfSuccessful: true) } - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", "https://xamjenkinsartifact.azureedge.net/mono-sdks/${packageFileName}", 'SUCCESS', packageFileName) + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", "https://xamjenkinsartifact.azureedge.net/mono-sdks/${packageFileName}", 'SUCCESS', packageFileName) } catch (Exception e) { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", env.BUILD_URL, 'FAILURE', "Build failed.") + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, "Archive-${product}-${configuration}-${platform}", env.BUILD_URL, 'FAILURE', "Build failed.") throw e } } diff --git a/scripts/ci/pipeline/utils.groovy b/scripts/ci/pipeline/utils.groovy deleted file mode 100644 index 813c7253d35..00000000000 --- a/scripts/ci/pipeline/utils.groovy +++ /dev/null @@ -1,11 +0,0 @@ -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 diff --git a/scripts/ci/pipeline/win-package.groovy b/scripts/ci/pipeline/win-package.groovy index 1f163f7c613..2f6f288da98 100644 --- a/scripts/ci/pipeline/win-package.groovy +++ b/scripts/ci/pipeline/win-package.groovy @@ -6,7 +6,6 @@ def macJobName = (isPr ? "build-package-osx-mono-pullrequest" : "build-package-o def packageFileNameX86 = null def packageFileNameX64 = null def commitHash = null -def utils = null // compression is incompatible with JEP-210 right now properties([ /* compressBuildLog() */]) @@ -26,8 +25,6 @@ try { // get current commit sha commitHash = sh (script: 'git rev-parse HEAD', returnStdout: true).trim() currentBuild.displayName = "${commitHash.substring(0,7)}" - - utils = load "scripts/ci/pipeline/utils.groovy" } stage('Download Mac .pkg from Azure') { @@ -40,8 +37,8 @@ try { } stage('Build') { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', env.BUILD_URL, 'PENDING', 'Building...') - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', env.BUILD_URL, 'PENDING', 'Building...') + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', env.BUILD_URL, 'PENDING', 'Building...') + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', env.BUILD_URL, 'PENDING', 'Building...') // build the .msi timeout (time: 420, unit: 'MINUTES') { @@ -103,12 +100,22 @@ try { 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 (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', packageUrlX86, 'SUCCESS', packageFileNameX86) - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', packageUrlX64, 'SUCCESS', packageFileNameX64) + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', packageUrlX86, 'SUCCESS', packageFileNameX86) + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', packageUrlX64, 'SUCCESS', packageFileNameX64) } } catch (Exception e) { - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', env.BUILD_URL, 'FAILURE', "Build failed.") - utils.reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', env.BUILD_URL, 'FAILURE', "Build failed.") + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x86', env.BUILD_URL, 'FAILURE', "Build failed.") + reportGitHubStatus (isPr ? env.ghprbActualCommit : commitHash, 'MSI-mono_x64', env.BUILD_URL, 'FAILURE', "Build failed.") throw e } + +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]]] + ]) +} |