Skip to content

Commit

Permalink
Update Jenkinsfile
Browse files Browse the repository at this point in the history
  • Loading branch information
michelu89 committed Feb 5, 2024
1 parent a2b23c5 commit 9ea56b8
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions .jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,25 @@ pipeline {
https://api.github.com/repos/${repo}/releases/tags/${tagName} | jq -r '.id'
""", returnStdout: true).trim()

def asset = sh(script: """
def assetId = 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"))'
"https://api.github.com/repos/${repo}/releases/${releaseId}/assets" | \\
jq '.[] | select(.name == "${fileName}").id'
""", 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" \\
-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}"
"""
if (assetId) {
sh "curl -s -X DELETE -H \"Authorization: Bearer \$GITHUB_TOKEN\" \"https://api.github.com/repos/${repo}/releases/assets/${assetId}\""
}

sh """
curl -L \
-X POST \
-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}"
"""
}
}
}
Expand Down

0 comments on commit 9ea56b8

Please sign in to comment.