[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'
|
String projectSettingFile = 'pyproject.toml'
|
||||||
Map gitVars = [:]
|
Map gitVars = [:]
|
||||||
String tag = ''
|
String tag = ''
|
||||||
|
String branch = git.getBranch()
|
||||||
|
|
||||||
Map configuration = [
|
Map configuration = [
|
||||||
vaultUrl: env.JENKINS_VAULT_URL,
|
vaultUrl: env.JENKINS_VAULT_URL,
|
||||||
@@ -46,7 +47,7 @@ slaveTemplates.jnlp {
|
|||||||
|
|
||||||
stage('Download sources') {
|
stage('Download sources') {
|
||||||
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
|
gitVars = git.clone([urlRepo: "${env.JENKINS_GIT_REPOSITORY_SSH_URL}/${repoPath}",
|
||||||
branch: git.getBranch()])
|
branch: branch])
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('prepare app'){
|
stage('prepare app'){
|
||||||
@@ -67,23 +68,20 @@ slaveTemplates.jnlp {
|
|||||||
String imageName = "${env.JENKINS_DOCKER_REGISTRY}/" +
|
String imageName = "${env.JENKINS_DOCKER_REGISTRY}/" +
|
||||||
"${dockerGroup}/${dockerProject}:${tag}"
|
"${dockerGroup}/${dockerProject}:${tag}"
|
||||||
|
|
||||||
stage('build image'){
|
docker.withRegistry("https://${env.JENKINS_DOCKER_REGISTRY}", env.JENKINS_HARBOR_CREDENTIALS) {
|
||||||
sh """#!/bin/sh
|
stage('build image and push'){
|
||||||
docker build --build-arg PIP_INDEX_URL=${env.JENKINS_PIP_INDEX_URL} \
|
Object buildImage = docker.build(imageName,
|
||||||
-f Dockerfile -t ${imageName} .
|
"--build-arg PIP_INDEX_URL=${env.JENKINS_PIP_INDEX_URL} -f Dockerfile ."
|
||||||
"""
|
)
|
||||||
}
|
|
||||||
|
|
||||||
stage('push image'){
|
if (branch == publishBranch) {
|
||||||
if (git.getBranch() == publishBranch){
|
buildImage.push()
|
||||||
sh """#!/bin/sh
|
}
|
||||||
docker login -u ${ciUser} -p '${dockerToken}' ${env.JENKINS_DOCKER_REGISTRY}
|
|
||||||
docker push ${imageName}
|
|
||||||
"""
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('deploy application'){
|
stage('deploy application'){
|
||||||
if (git.getBranch() == publishBranch){
|
if (branch == publishBranch){
|
||||||
build job: 'Cloud/Deploy/Backend/msg-messenger-core-api-deploy',
|
build job: 'Cloud/Deploy/Backend/msg-messenger-core-api-deploy',
|
||||||
parameters: [
|
parameters: [
|
||||||
string(name: 'ENV', value: 'DEV'),
|
string(name: 'ENV', value: 'DEV'),
|
||||||
|
|||||||
Reference in New Issue
Block a user