Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/56 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>
74 lines
2.3 KiB
Groovy
74 lines
2.3 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()
|
|
])
|
|
|
|
String repoPath = 'Apps-Frontend/cloud-messenger-uikit.git'
|
|
String publishBranch = 'develop'
|
|
String nexusRepoName = 'tavro-cloud-npm-feature'
|
|
String maintainerUser = ''
|
|
|
|
Git git = new Git(this, env.JENKINS_GIT_CREDENTIALS_SSH)
|
|
PodTemplates slaveTemplates = new PodTemplates(this, env.JENKINS_DOCKER_REGISTRY, ["${env.JENKINS_K8S_HARBOR_SECRET}"])
|
|
Nexus nexus = new Nexus(this, env.JENKINS_NEXUS_URL, env.JENKINS_NEXUS_CREDENTIALS)
|
|
|
|
slaveTemplates.jnlp {
|
|
slaveTemplates.nodejs(imageVersion='18.16-alpine3.18') {
|
|
try {
|
|
node(POD_LABEL){
|
|
stage('Download sources') {
|
|
git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}", branch: git.getBranch()])
|
|
}
|
|
|
|
container('nodejs'){
|
|
stage('build'){
|
|
sh """
|
|
npm config set registry ${env.JENKINS_NEXUS_NPM_REPOSITORY}
|
|
npm install
|
|
npm run build
|
|
npm pack
|
|
"""
|
|
}
|
|
|
|
if (git.getBranch() == publishBranch){
|
|
maintainerUser = 'rishat.gabaidullov@avroid.team'
|
|
|
|
stage('upload artifact'){
|
|
String artifact = sh( script: "ls *.tgz", returnStdout: true).trim()
|
|
|
|
nexus.uploadNpmArtifact(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: maintainerUser
|
|
)
|
|
}
|
|
}
|
|
}
|