Ajout d'une méthode gitea.release()
This commit is contained in:
@ -3,7 +3,7 @@ def commentPullRequest(String repo, String issueId, String comment, Integer comm
|
||||
withCredentials([
|
||||
string(credentialsId: 'GITEA_JENKINS_PERSONAL_TOKEN', variable: 'GITEA_TOKEN'),
|
||||
]) {
|
||||
writeFile(file: ".prComment", text: comment)
|
||||
writeFile(file: '.prComment', text: comment)
|
||||
sh """#!/bin/bash
|
||||
set -xeo pipefail
|
||||
|
||||
@ -37,4 +37,62 @@ def commentPullRequest(String repo, String issueId, String comment, Integer comm
|
||||
fi
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Effectue une "release" sur Gitea pour le <ORG>/<PROJET> donné.
|
||||
def release(String credentialsId, String org, String project, Map options = [:]) {
|
||||
def isDraft = options.get('isDraft', false)
|
||||
def baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')
|
||||
def defaultVersion = sh(returnStdout: true, script: 'git describe --always').trim()
|
||||
def releaseVersion = options.get('releaseVersion', defaultVersion)
|
||||
def commitishTarget = options.get('commitishTarget', env.GIT_COMMIT)
|
||||
|
||||
def defaultIsPrerelease = true
|
||||
try {
|
||||
sh(script: "git describe --exact-match ${GIT_COMMIT}")
|
||||
defaultIsPrerelease = false
|
||||
} catch (err) {
|
||||
println "Could not find tag associated with commit '${GIT_COMMIT}' ! Using 'prerelease' as default."
|
||||
}
|
||||
|
||||
def isPrerelease = options.get('isPrerelease', defaultIsPrerelease)
|
||||
def body = options.get('body', '')
|
||||
def attachments = options.get('attachments', [])
|
||||
|
||||
def scriptTempDir = ".gitea-release-script-${System.currentTimeMillis()}"
|
||||
sh("mkdir -p '${scriptTempDir}'")
|
||||
|
||||
def giteaReleaseScript = "${scriptTempDir}/gitea-release.sh"
|
||||
|
||||
def giteaReleaseScriptContent = libraryResource 'com/cadoles/gitea/gitea-release.sh'
|
||||
writeFile file: giteaReleaseScript, text:giteaReleaseScriptContent
|
||||
sh("chmod +x '${giteaReleaseScript}'")
|
||||
|
||||
try {
|
||||
withCredentials([
|
||||
usernamePassword(
|
||||
credentialsId: credentialsId,
|
||||
usernameVariable: 'GITEA_RELEASE_USERNAME',
|
||||
passwordVariable: 'GITEA_RELEASE_PASSWORD'
|
||||
)
|
||||
]) {
|
||||
sh """
|
||||
export GITEA_RELEASE_PROJECT="${project}"
|
||||
export GITEA_RELEASE_ORG="${org}"
|
||||
export GITEA_RELEASE_BASE_URL="${baseUrl}"
|
||||
export GITEA_RELEASE_VERSION="${releaseVersion}"
|
||||
export GITEA_RELEASE_COMMITISH_TARGET="${commitishTarget}"
|
||||
export GITEA_RELEASE_IS_DRAFT="${isDraft}"
|
||||
export GITEA_RELEASE_IS_PRERELEASE="${isPrerelease}"
|
||||
export GITEA_RELEASE_BODY="${body}"
|
||||
export GITEA_RELEASE_ATTACHMENTS="${attachments.join(' ')}"
|
||||
|
||||
${giteaReleaseScript}
|
||||
"""
|
||||
}
|
||||
} finally {
|
||||
dir(scriptTempDir) {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user