From a2b23c59ecbc0f0124aac13989e1a439c63b6ce8 Mon Sep 17 00:00:00 2001 From: Michele Santoro Date: Mon, 5 Feb 2024 12:52:58 +0100 Subject: [PATCH] Update Jenkinsfile --- .jenkins/Jenkinsfile | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/.jenkins/Jenkinsfile b/.jenkins/Jenkinsfile index 010086d3..6a181bae 100644 --- a/.jenkins/Jenkinsfile +++ b/.jenkins/Jenkinsfile @@ -31,14 +31,6 @@ pipeline { def tagName = "v5.2.1" def fileName = "signed.exe" - sh """ - curl -L \\ - -H "Accept: application/vnd.github+json" \\ - -H "Authorization: Bearer " \\ - -H "X-GitHub-Api-Version: 2022-11-28" \\ - https://api.github.com/repos/${repo}/releases/tags/${tagName} - - """ def releaseId = sh(script: """ curl -s -L \\ -H "Accept: application/vnd.github+json" \\ @@ -46,7 +38,24 @@ pipeline { https://api.github.com/repos/${repo}/releases/tags/${tagName} | jq -r '.id' """, returnStdout: true).trim() - sh """ + def asset = sh(script: """ + curl -s -H "Authorization: Bearer \$GITHUB_TOKEN" \\ + -H "Accept: application/vnd.github+json" \\ + https://api.github.com/repos/${repo}/releases/${releaseId}/assets | jq -c '.[] | select(.name | endswith(".exe"))' + """, returnStdout: true).trim() + + if (asset) { + sh """ + curl -L \ + -X PATCH \ + -H "Accept: application/vnd.github+json" \\ + -H "Authorization: Bearer \$GITHUB_TOKEN" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @${fileName} \ + "https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileName}" + """ + } else { + sh """ curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \\ @@ -54,7 +63,8 @@ pipeline { -H "Content-Type: application/octet-stream" \ --data-binary @${fileName} \ "https://uploads.github.com/repos/${repo}/releases/${releaseId}/assets?name=${fileName}" - """ + """ + } } } }