[DO-1239] add_backend_ci (!48)
добавил pipeline для сборки cloud-messenger-backend-api Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/48 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:
committed by
Denis Patrakeev
parent
4ed0e6f48a
commit
c4d5987382
77
pipelines/Cloud/Apps-Backend/cloud-messenger-core-api.groovy
Normal file
77
pipelines/Cloud/Apps-Backend/cloud-messenger-core-api.groovy
Normal file
@@ -0,0 +1,77 @@
|
||||
@Library('shared-lib') _
|
||||
|
||||
import tech.avroid.kube.PodTemplates
|
||||
import tech.avroid.scm.Git
|
||||
|
||||
Git git = new Git(this, env.JENKINS_GIT_CREDENTIALS_SSH)
|
||||
|
||||
String repoPath = 'Apps-Backend/cloud-messenger-core-api.git'
|
||||
String ciUser = 'robot\$\$ci'
|
||||
String publishBranch = 'develop'
|
||||
|
||||
Map configuration = [
|
||||
vaultUrl: 'https://vault.avroid.tech',
|
||||
vaultCredentialId: 'vault-role',
|
||||
engineVersion: 2
|
||||
]
|
||||
|
||||
List dockerCreds = [
|
||||
[path: 'team-devops/services/registry/Harbor/harbor.avroid.tech', engineVersion: 2,
|
||||
secretValues:
|
||||
[
|
||||
[vaultKey: 'service.user.ci.login'],
|
||||
[vaultKey: 'service.user.ci.token'],
|
||||
]
|
||||
]
|
||||
]
|
||||
|
||||
slaveTemplates = new PodTemplates(this, env.JENKINS_DOCKER_REGISTRY, ["${env.JENKINS_K8S_HARBOR_SECRET}"])
|
||||
|
||||
slaveTemplates.jnlp {
|
||||
slaveTemplates.poetry {
|
||||
slaveTemplates.docker {
|
||||
node(POD_LABEL){
|
||||
|
||||
stage('Download sources') {
|
||||
git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
|
||||
branch: git.getBranch()])
|
||||
}
|
||||
|
||||
stage('prepare app'){
|
||||
container('poetry'){
|
||||
sh 'make setup'
|
||||
}
|
||||
}
|
||||
|
||||
withVault([configuration: configuration, vaultSecrets: dockerCreds]) {
|
||||
String dockerToken = getProperty('service.user.ci.token')
|
||||
String makeArgs = " DOCKER_REGISTRY='${env.JENKINS_DOCKER_REGISTRY}'" +
|
||||
" DOCKER_REGISTRY_USER='${ciUser}'" +
|
||||
" DOCKER_REGISTRY_PASSWORD='${dockerToken}'"
|
||||
|
||||
container('docker'){
|
||||
stage('build image'){
|
||||
sh """#!/bin/sh
|
||||
apk add make
|
||||
make build-image ${makeArgs}
|
||||
"""
|
||||
}
|
||||
|
||||
stage('push image'){
|
||||
sh """#!/bin/sh
|
||||
apk add make
|
||||
make build-image ${makeArgs}
|
||||
"""
|
||||
|
||||
if (git.getBranch() == publishBranch){
|
||||
sh """#!/bin/sh
|
||||
make push-image ${makeArgs}
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user