feat(gitea): add uploadPackage() helper
This commit is contained in:
parent
4c15ad01c5
commit
b54de01dea
@ -10,6 +10,8 @@ GITEA_PACKAGE_FILE=${GITEA_PACKAGE_FILE}
|
|||||||
GITEA_PACKAGE_CURL_MAX_RETRY=${GITEA_PACKAGE_CURL_MAX_RETRY:-3}
|
GITEA_PACKAGE_CURL_MAX_RETRY=${GITEA_PACKAGE_CURL_MAX_RETRY:-3}
|
||||||
GITEA_PACKAGE_FORCE_OVERWRITE=${GITEA_PACKAGE_FORCE_UPLOAD:-yes}
|
GITEA_PACKAGE_FORCE_OVERWRITE=${GITEA_PACKAGE_FORCE_UPLOAD:-yes}
|
||||||
|
|
||||||
|
GITEA_PACKAGE_RPM_GROUP=${GITEA_PACKAGE_RPM_GROUP:-main}
|
||||||
|
|
||||||
GITEA_PACKAGE_DEBIAN_DISTRIBUTION=${GITEA_PACKAGE_DEBIAN_DISTRIBUTION:-latest}
|
GITEA_PACKAGE_DEBIAN_DISTRIBUTION=${GITEA_PACKAGE_DEBIAN_DISTRIBUTION:-latest}
|
||||||
GITEA_PACKAGE_DEBIAN_COMPONENT=${GITEA_PACKAGE_DEBIAN_COMPONENT:-main}
|
GITEA_PACKAGE_DEBIAN_COMPONENT=${GITEA_PACKAGE_DEBIAN_COMPONENT:-main}
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ function upload_alpine_package {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function upload_redhat_package {
|
function upload_redhat_package {
|
||||||
gitea_api "/api/packages/$GITEA_PACKAGE_ORG/rpm/upload" \
|
gitea_api "/api/packages/$GITEA_PACKAGE_ORG/rpm/${GITEA_PACKAGE_RPM_GROUP}/upload" \
|
||||||
--upload-file "$GITEA_PACKAGE_FILE"
|
--upload-file "$GITEA_PACKAGE_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import java.io.File
|
||||||
|
|
||||||
def commentPullRequest(String repo, String issueId, String comment, Integer commentIndex = -1) {
|
def commentPullRequest(String repo, String issueId, String comment, Integer commentIndex = -1) {
|
||||||
comment = comment.replaceAll('"', '\\"')
|
comment = comment.replaceAll('"', '\\"')
|
||||||
withCredentials([
|
withCredentials([
|
||||||
@ -115,6 +117,71 @@ 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, String project, List<String> packageFiles, Map options = [:]) {
|
||||||
|
String baseUrl = options.get('baseUrl', 'https://forge.cadoles.com')
|
||||||
|
String debianDistribution = options.get('debianDistribution', 'latest')
|
||||||
|
String debianComponent = options.get('debianComponent', 'main')
|
||||||
|
String rpmGroup = options.get('rpmGroup', 'main')
|
||||||
|
String alpineBranch = options.get('alpineBranch', 'latest')
|
||||||
|
String alpineRepository = options.get('alpineRepository', 'main')
|
||||||
|
|
||||||
|
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="${file}"
|
||||||
|
|
||||||
|
export GITEA_PACKAGE_RPM_GROUP="${rpmGroup}"
|
||||||
|
|
||||||
|
export GITEA_PACKAGE_DEBIAN_DISTRIBUTION="${debianDistribution}"
|
||||||
|
export GITEA_PACKAGE_DEBIAN_COMPONENT="${debianComponent}"
|
||||||
|
|
||||||
|
export GITEA_PACKAGE_ALPINE_BRANCH="${alpineBranch}"
|
||||||
|
export GITEA_PACKAGE_ALPINE_REPOSITORY="${alpineRepository}"
|
||||||
|
|
||||||
|
${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{ "- `${ new File(it).name }`" }).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')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user