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
41aa8d8a
Commit
41aa8d8a
authored
Oct 13, 2023
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 @
41aa8d8a
...
@@ -10,18 +10,46 @@ pipeline {
...
@@ -10,18 +10,46 @@ pipeline {
stage
(
'Build and Create Docker Image'
)
{
stage
(
'Build and Create Docker Image'
)
{
steps
{
steps
{
sh
'npm install'
script
{
sh
'npm run build'
def
branchName
=
BRANCH_NAME
sh
'docker build -t sulemantalpur6/frontend:latest .'
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'
)
{
stage
(
'Push Docker Image to Docker Hub'
)
{
steps
{
steps
{
withCredentials
([
usernamePassword
(
credentialsId:
'dockerHub'
,
usernameVariable:
'DOCKER_HUB_USERNAME'
,
passwordVariable:
'DOCKER_HUB_PASSWORD'
)])
{
script
{
sh
"docker login -u $DOCKER_HUB_USERNAME -p $DOCKER_HUB_PASSWORD"
def
branchName
=
currentBuild
.
displayName
sh
"docker push sulemantalpur6/frontend:latest"
}
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"
}
}
}
}
}
}
}
}
}
}
}
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