diff --git a/vars/gitea.groovy b/vars/gitea.groovy index 19880d6..d8cbeac 100644 --- a/vars/gitea.groovy +++ b/vars/gitea.groovy @@ -115,6 +115,57 @@ void release(String credentialsId, String org, String project, Map options = [:] ) } +// Téléverse une liste de paquets sur Gitea pour le / donné. +void uploadPackages(String credentialsId, String org, List 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): + ${ (packageFiles.collect{ "- ${it}" }).join('\n') } + + [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')