From 085e38d2d350a43668784304194619eddf4d5d7c Mon Sep 17 00:00:00 2001 From: Jonas Bovin Date: Fri, 9 Dec 2022 11:59:59 +0100 Subject: [PATCH 1/2] Added error handling --- dist/index.js | 20 ++++++++++++++++---- src/se.ts | 19 +++++++++++++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index f44618829..bdcd7e1e0 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13636,10 +13636,22 @@ class se_Helper { createMetaJson(root) { const execSync = external_child_process_.execSync; console.log('Run number: ' + this.currentBuild.runNumber); - const xmllint = execSync('sudo apt install libxml2-utils', { - shell: '/bin/bash' - }); - console.log(xmllint.toString()); + try { + const xmllint = execSync('sudo apt install libxml2-utils', { + shell: '/bin/bash' + }); + console.log(xmllint.toString()); + } + catch (err) { + let message; + if (err instanceof Error) { + message = err.message; + } + else { + message = String(err); + } + console.log(message); + } const ret = []; const poms = this.listPoms(root); const ownersFile = Object(external_fs_.readFileSync)(root + '.github/CODEOWNERS', 'utf8') diff --git a/src/se.ts b/src/se.ts index 16d077988..cd54d8a87 100644 --- a/src/se.ts +++ b/src/se.ts @@ -46,10 +46,21 @@ export class Helper { public createMetaJson(root: string) { const execSync = child.execSync console.log('Run number: ' + this.currentBuild.runNumber) - const xmllint = execSync('sudo apt install libxml2-utils', { - shell: '/bin/bash' - }) - console.log(xmllint.toString()) + try { + const xmllint = execSync('sudo apt install libxml2-utils', { + shell: '/bin/bash' + }) + + console.log(xmllint.toString()) + } catch (err) { + let message + if (err instanceof Error) { + message = err.message + } else { + message = String(err) + } + console.log(message) + } const ret: string[] = [] const poms = this.listPoms(root) const ownersFile = fs From b10f6d2a4437b61d97cd0c8855aa746b7971b160 Mon Sep 17 00:00:00 2001 From: Jonas Bovin Date: Fri, 9 Dec 2022 12:28:47 +0100 Subject: [PATCH 2/2] Run apt-get first --- dist/index.js | 2 +- src/se.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index bdcd7e1e0..c98fd9bf7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -13637,7 +13637,7 @@ class se_Helper { const execSync = external_child_process_.execSync; console.log('Run number: ' + this.currentBuild.runNumber); try { - const xmllint = execSync('sudo apt install libxml2-utils', { + const xmllint = execSync('sudo apt-get update; sudo apt install libxml2-utils', { shell: '/bin/bash' }); console.log(xmllint.toString()); diff --git a/src/se.ts b/src/se.ts index cd54d8a87..4fb91dacb 100644 --- a/src/se.ts +++ b/src/se.ts @@ -47,9 +47,12 @@ export class Helper { const execSync = child.execSync console.log('Run number: ' + this.currentBuild.runNumber) try { - const xmllint = execSync('sudo apt install libxml2-utils', { - shell: '/bin/bash' - }) + const xmllint = execSync( + 'sudo apt-get update; sudo apt install libxml2-utils', + { + shell: '/bin/bash' + } + ) console.log(xmllint.toString()) } catch (err) {