Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
user-service
Commits
0d11d32f
Unverified
Commit
0d11d32f
authored
2 years ago
by
Abhishek Mishra
Committed by
GitHub
2 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #58 from tushar5526/patch-1
Update Jenkinsfile
parents
6022dcb9
64886356
master
v2.4.4
v2.4.3
v2.4.2
v2.4.1
v2.4.0
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
build/Jenkinsfile
+23
-17
build/Jenkinsfile
with
23 additions
and
17 deletions
+23
-17
build/Jenkinsfile
+
23
−
17
View file @
0d11d32f
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
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets