feat(gitea): add uploadPackage() helper

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

View File

@ -115,6 +115,54 @@ void release(String credentialsId, String org, String project, Map options = [:]
)
}
// Téléverse un paquet sur Gitea pour le <ORG>/<PROJET> donné.
void uploadPackage(String credentialsId, String org, String project, String packageFile, 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'
)
]) {
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 paquet publié pour le projet `${org}/${project}`: [${packageFile}](${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')