feat(gitea): add uploadPackage() helper
This commit is contained in:
@ -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 <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):
|
||||||
|
${ (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
|
// 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 = [:]) {
|
void download(String credentialsId, String org, String project, Map options = [:]) {
|
||||||
String baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')
|
String baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')
|
||||||
|
Reference in New Issue
Block a user