Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DevOps Assignment
frontend
Commits
30ed8e82
Commit
30ed8e82
authored
1 year ago
by
Muhammad Suleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Jenkinsfile
parent
2b98ed9c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
7 deletions
+35
-7
Jenkinsfile
Jenkinsfile
+35
-7
No files found.
Jenkinsfile
View file @
30ed8e82
...
...
@@ -10,18 +10,46 @@ pipeline {
stage
(
'Build and Create Docker Image'
)
{
steps
{
sh
'npm install'
sh
'npm run build'
sh
'docker build -t sulemantalpur6/frontend:latest .'
script
{
def
branchName
=
BRANCH_NAME
def
imageName
echo
branchName
;
if
(
branchName
==
'dev'
)
{
imageName
=
'sulemantalpur6/frontend:dev'
}
else
if
(
branchName
==
'master'
)
{
imageName
=
'sulemantalpur6/frontend:master'
}
else
if
(
branchName
==
'QA'
)
{
imageName
=
'sulemantalpur6/frontend:QA'
}
else
if
(
branchName
==
'UAT'
)
{
imageName
=
'sulemantalpur6/frontend:UAT'
}
else
{
echo
"Branch $branchName not configured for Docker image build."
currentBuild
.
result
=
'FAILURE'
return
}
sh
'npm install'
sh
'npm run build'
sh
"docker build -t $imageName ."
}
}
}
stage
(
'Push Docker Image to Docker Hub'
)
{
steps
{
withCredentials
([
usernamePassword
(
credentialsId:
'dockerHub'
,
usernameVariable:
'DOCKER_HUB_USERNAME'
,
passwordVariable:
'DOCKER_HUB_PASSWORD'
)])
{
sh
"docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD"
sh
"docker push sulemantalpur6/frontend:latest"
}
script
{
def
branchName
=
currentBuild
.
displayName
if
(
branchName
==
'dev'
||
branchName
==
'master'
||
branchName
==
'QA'
||
branchName
==
'UAT'
)
{
withCredentials
([
usernamePassword
(
credentialsId:
'dockerHub'
,
usernameVariable:
'DOCKER_HUB_USERNAME'
,
passwordVariable:
'DOCKER_HUB_PASSWORD'
)])
{
sh
"docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD"
sh
"docker push sulemantalpur6/frontend:$branchName"
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment