@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.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 -> println "Upload artifact ${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 ) } } } } }