feat(gitea): add uploadPackage() helper

This commit is contained in:
wpetit 2025-04-02 15:32:25 +02:00
parent 4c15ad01c5
commit 658f804763

View File

@ -115,6 +115,56 @@ void release(String credentialsId, String org, String project, Map options = [:]
)
}
// Téléverse une liste de paquets sur Gitea pour le <ORG>/<PROJET> donné.
void uploadPackages(String credentialsId, String org, List<String> packageFiles, Map options = [:]) {
String baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')
String scriptTempDir = ".gitea-package-script-${System.currentTimeMillis()}"
sh("mkdir -p '${scriptTempDir}'")
String giteaPackageScript = "${scriptTempDir}/gitea-package.sh"
String giteaPackageScriptContent = libraryResource 'com/cadoles/gitea/gitea-package.sh'
writeFile file: giteaPackageScript, text:giteaPackageScriptContent
sh("chmod +x '${giteaPackageScript}'")
try {
withCredentials([
usernamePassword(
credentialsId: credentialsId,
usernameVariable: 'GITEA_PACKAGE_USERNAME',
passwordVariable: 'GITEA_PACKAGE_PASSWORD'
)
]) {
packageFiles.each { file ->
sh """
export GITEA_PACKAGE_PROJECT="${project}"
export GITEA_PACKAGE_ORG="${org}"
export GITEA_PACKAGE_FILE="${packageFile}"
${giteaPackageScript}
"""
}
}
} finally {
dir(scriptTempDir) {
deleteDir()
}
}
rocketSend(
avatar: 'https://jenkins.cadol.es/static/b5f67753/images/headshot.png',
message: """
Nouveau(x) paquet(s) publié(s) pour le projet [${org}/${project}](${baseUrl}/${org}/-/packages):
[Visualiser le job](${env.RUN_DISPLAY_URL})
@${utils.getBuildUser()}
""".stripIndent(),
rawMessage: true
)
}
// Télécharge les fichiers associés à une "version" publiée sur un projet Gitea
void download(String credentialsId, String org, String project, Map options = [:]) {
String baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')