Unverified Commit 0d11d32f authored by Abhishek Mishra's avatar Abhishek Mishra Committed by GitHub
Browse files

Merge pull request #58 from tushar5526/patch-1

Update Jenkinsfile
No related merge requests found
Showing with 23 additions and 17 deletions
+23 -17
node() {
properties([
parameters([
string(name: 'docker_repo', defaultValue: 'user-service', description: 'Docker Image Name'),
string(name: 'docker_server', defaultValue: 'localhost:5000', description: 'Docker Registry URL'),
withCredentials([string(credentialsId: 'docker_server', variable: 'docker_server')]) {
properties([
parameters([
string(name: 'docker_repo', defaultValue: 'samagragovernance/esamwad-user-service', description: 'Docker Image Name'),
string(name: 'docker_server', defaultValue: "$docker_server", description: 'Docker Registry URL'),
])
])
])
}
stage('Checkout') {
cleanWs()
checkout scm
commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
env.commit_id = sh(script: 'echo ' + env.docker_repo + '_' + commit_hash + '_' + env.BRANCH_NAME, returnStdout: true).trim()
env.commit_id = env.BRANCH_NAME
echo "${env.commit_id}"
}
stage('docker-build') {
sh '''
docker build -f build/Dockerfile -t $docker_server/$docker_repo:$commit_id .
'''
if (env.BRANCH_NAME == 'main' || env.BRANCH_NAME == 'master') {
sh '''
docker build -f build/Dockerfile -t $docker_server/$docker_repo:$commit_id .
'''
docker build -f build/Dockerfile -t $docker_server/$docker_repo:$commit_id .
'''
}
}
stage('docker-push') {
sh '''
docker push $docker_server/$docker_repo:$commit_id
'''
}
stage('ArchiveArtifacts') {
sh("echo ${commit_id} > commit_id.txt")
archiveArtifacts 'commit_id.txt'
currentBuild.description = "${commit_id}"
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
'''
}
}
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment