[DO-1519] some refactoring (!78)
Co-authored-by: Rustam Tagaev <rustam.tagaev@avroid.tech> Reviewed-on: https://git.avroid.tech/DevOps/jenkins-pipelines/pulls/78
This commit is contained in:
@@ -20,6 +20,7 @@ String dockerProject = 'msg-messenger-core-api'
|
||||
String projectSettingFile = 'pyproject.toml'
|
||||
Map gitVars = [:]
|
||||
String tag = ''
|
||||
String branch = git.getBranch()
|
||||
|
||||
Map configuration = [
|
||||
vaultUrl: env.JENKINS_VAULT_URL,
|
||||
@@ -28,7 +29,7 @@ Map configuration = [
|
||||
]
|
||||
|
||||
List dockerCreds = [
|
||||
[path: 'team-devops/services/registry/Harbor/harbor.avroid.tech', engineVersion: 2,
|
||||
[path: 'team-devops/services/registry/Harbor/harbor.avroid.tech', engineVersion: 2,
|
||||
secretValues:
|
||||
[
|
||||
[vaultKey: 'service.user.jenkins.ci.login'],
|
||||
@@ -46,7 +47,7 @@ slaveTemplates.jnlp {
|
||||
|
||||
stage('Download sources') {
|
||||
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
|
||||
branch: git.getBranch()])
|
||||
branch: branch])
|
||||
}
|
||||
|
||||
stage('prepare app'){
|
||||
@@ -67,23 +68,20 @@ slaveTemplates.jnlp {
|
||||
String imageName = "${env.JENKINS_DOCKER_REGISTRY}/" +
|
||||
"${dockerGroup}/${dockerProject}:${tag}"
|
||||
|
||||
stage('build image'){
|
||||
sh """#!/bin/sh
|
||||
docker build --build-arg PIP_INDEX_URL=${env.JENKINS_PIP_INDEX_URL} \
|
||||
-f Dockerfile -t ${imageName} .
|
||||
"""
|
||||
}
|
||||
docker.withRegistry("https://${env.JENKINS_DOCKER_REGISTRY}", env.JENKINS_HARBOR_CREDENTIALS) {
|
||||
stage('build image and push'){
|
||||
Object buildImage = docker.build(imageName,
|
||||
"--build-arg PIP_INDEX_URL=${env.JENKINS_PIP_INDEX_URL} -f Dockerfile ."
|
||||
)
|
||||
|
||||
stage('push image'){
|
||||
if (git.getBranch() == publishBranch){
|
||||
sh """#!/bin/sh
|
||||
docker login -u ${ciUser} -p '${dockerToken}' ${env.JENKINS_DOCKER_REGISTRY}
|
||||
docker push ${imageName}
|
||||
"""
|
||||
if (branch == publishBranch) {
|
||||
buildImage.push()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stage('deploy application'){
|
||||
if (git.getBranch() == publishBranch){
|
||||
if (branch == publishBranch){
|
||||
build job: 'Cloud/Deploy/Backend/msg-messenger-core-api-deploy',
|
||||
parameters: [
|
||||
string(name: 'ENV', value: 'DEV'),
|
||||
|
||||
Reference in New Issue
Block a user