Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/51 Reviewed-by: Denis Patrakeev <denis.patrakeev@avroid.team> Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.team> Co-committed-by: Rustam Tagaev <rustam.tagaev@avroid.team>
94 lines
3.5 KiB
Groovy
94 lines
3.5 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 artifactUrl = "${env.JENKINS_NEXUS_URL}/repository/${nexusRepoName}"
|
|
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}"
|
|
|
|
dir(localArtifactDir){
|
|
String artifact = sh(
|
|
script: """#!/bin/sh
|
|
ls *.whl
|
|
""",
|
|
returnStdout: true).trim()
|
|
print 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
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|