Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions build/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,41 @@ node() {
}

stage('docker-build') {
sh '''
docker build -t $docker_server/$docker_repo:$commit_id .
'''
if (env.BRANCH_NAME == 'staging') {
sh '''
docker build -t $docker_server/$docker_repo:latest .
'''
}
sh '''
docker build -t $docker_server/$docker_repo:$commit_id .
'''
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') {
sh '''
docker build -t $docker_server/$docker_repo:latest .
'''
} else if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'staging'){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the logic here, and why for both main and staging? we are building latest tagged repo ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is written
if any changes happens at main branch then it will pickup the command mentioned in that and if any changes push on staging then it will take that changes
and also in last stage it will deploy it according to changes pushed to respective
branch

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For main, it will never go to the second if. Please walk through the if else logic once. Also verify the tags again.

Copy link
Copy Markdown
Collaborator Author

@AbhilashKD AbhilashKD May 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes
but if it is for staging then ?
then it will go for 2nd na
?

sh '''
docker build -t $docker_server/$docker_repo:latest .
'''
}
}

stage('docker-push') {
sh '''
docker push $docker_server/$docker_repo:$commit_id
'''
if (env.BRANCH_NAME == 'staging') {
sh '''
docker push $docker_server/$docker_repo:staging
'''
}
sh '''
docker push $docker_server/$docker_repo:$commit_id
'''
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') {
sh '''
docker push $docker_server/$docker_repo:latest
'''
} else if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'staging'){
sh '''
docker push $docker_server/$docker_repo:staging
'''
}
}

stage('Start deploy job with latest tag') {
if (env.BRANCH_NAME == 'staging') {
build job: 'UAT/deploy-uat/ulp-bff/', parameters: [string(name: 'tag', value: 'staging')]
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') {
build job: 'ULP/deploy-staging/ulp-bff/', parameters: [string(name: 'tag', value: 'latest')]
}
else if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'staging'){
build job: 'UAT/deploy-staging/uat-bff/', parameters: [string(name: 'tag', value: 'latest'')]
}
}

}