Files
jenkins-pipelines/pipelines/Cloud/Apps-Backend/avroid-service-lib.groovy
Rustam Tagaev 357a89bcd4 [DO-1670] add msg files to test env (!96)
Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech>
Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/96
Reviewed-by: Vasiliy Chipizhin <vasiliy.chipizhin@avroid.team>
Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team>
2025-03-06 15:20:27 +03:00

96 lines
3.6 KiB
Groovy

@Library('shared-lib') _
import tech.avroid.kube.PodTemplates
import tech.avroid.scm.Git
import tech.avroid.api.Nexus
import tech.avroid.jenkins.Notifications
properties([
buildDiscarder(logRotator(artifactDaysToKeepStr: '',
artifactNumToKeepStr: '30',
daysToKeepStr: '',
numToKeepStr: '30')),
disableConcurrentBuilds()
])
Git git = new Git(this, env.JENKINS_GIT_CREDENTIALS_SSH)
Nexus nexus = new Nexus(this, env.JENKINS_NEXUS_URL, env.JENKINS_NEXUS_CREDENTIALS)
String repoPath = 'Apps-Backend/avroid-service-lib.git'
String nexusRepoName = 'tavro-cloud-pypi-release'
String localArtifactDir = './dist'
Map gitVars = [:]
Map author = [:]
slaveTemplates = new PodTemplates(this, env.JENKINS_DOCKER_REGISTRY, ["${env.JENKINS_K8S_HARBOR_SECRET}"])
slaveTemplates.jnlp {
slaveTemplates.poetry {
slaveTemplates.docker {
slaveTemplates.git {
node(POD_LABEL){
try {
container('poetry'){
stage('Download sources') {
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
branch: git.getBranch()])
}
stage('prepare app'){
sh 'make setup'
}
stage('build lib'){
sh 'make build'
}
}
container('git'){
stage('push lib to nexus'){
author = git.getAuthor(commit: gitVars.GIT_COMMIT)
if (env.TAG_NAME) {
print "Upload from tag ${env.TAG_NAME}"
currentBuild.description = env.TAG_NAME
dir(localArtifactDir){
String artifacts = sh(
script: """#!/bin/sh
ls *.whl *.gz
""",
returnStdout: true).trim()
artifacts.split().each { artifact ->
nexus.uploadPypiArtifact(
artifact: "${artifact}",
repository: nexusRepoName
)
}
}
}
}
}
} catch (err) {
errorMessage = err.getMessage()
println 'ERROR: ' + errorMessage
currentBuild.result = 'FAILURE'
String emailSubject = "${currentBuild.currentResult}. " +
"Pipeline task: ${currentBuild.fullDisplayName}"
Notifications.email(
script: this,
subject: emailSubject,
errorString: errorMessage,
recipientProviders: [],
to: author.email
)
}
}
}
}
}
}