[DO-1395] add_new_job (!56)

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>
This commit is contained in:
Rustam Tagaev
2024-12-11 19:11:18 +03:00
committed by Denis Patrakeev
parent 29e0bebe35
commit b62d3069f0
6 changed files with 178 additions and 9 deletions

View File

@@ -18,7 +18,6 @@ Nexus nexus = new Nexus(this, env.JENKINS_NEXUS_URL, env.JENKINS_NEXUS_CREDENTIA
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 = [:]

View File

@@ -0,0 +1,73 @@
@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
)
}
}
}