Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
B
building-a-multibranch-pipeline-project
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
谢宇轩
building-a-multibranch-pipeline-project
Commits
fb59b693
Commit
fb59b693
authored
Jun 21, 2022
by
谢宇轩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit jenkins file
parent
7a7ea1b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
4 deletions
+76
-4
Jenkinsfile
Jenkinsfile
+76
-4
No files found.
Jenkinsfile
View file @
fb59b693
pipeline
{
pipeline
{
agent
any
agent
{
docker
{
image
'node:6-alpine'
args
'-p 3000:3000 -p 5000:5000'
}
}
environment
{
CI
=
'true'
}
parameters
{
choice
(
choices:
[
'Deploy'
,
'Rollback'
],
description:
'''Deploy:【发布】
Rollback:【回滚】'''
,
name:
'Deploy'
)
gitParameter
(
requiredParameter:
true
,
description:
'Version:【版本】'
,
name:
'DeployVersion'
,
selectedValue:
'TOP'
,
sortMode:
'DESCENDING_SMART'
,
type:
'PT_TAG'
)
}
stages
{
stages
{
stage
(
'Build'
)
{
stage
(
'Build dev'
)
{
when
{
branch
'developer'
}
steps
{
sh
'npm install'
}
}
stage
(
'Build master'
)
{
when
{
branch
'master'
}
steps
{
script
{
if
(
params
.
Deploy
==
"Rollback"
)
{
echo
"回滚到 $DeployVersion 版本"
sh
"git reset --hard $DeployVersion"
}
else
{
echo
"拉取 $DeployVersion 版本"
sh
"git checkout $DeployVersion"
}
}
sh
'npm install'
}
}
stage
(
'Test'
)
{
steps
{
sh
'echo "testing!"'
echo
"test complete!"
}
}
stage
(
'Deliver for development'
)
{
when
{
branch
'developer'
}
steps
{
sh
'./jenkins/scripts/deliver-for-development.sh'
input
message:
'Finished using the web site? (Click "Proceed" to continue)'
sh
'./jenkins/scripts/kill.sh'
}
}
stage
(
'Deploy for production'
)
{
when
{
branch
'master'
}
steps
{
steps
{
sh
'echo "Hello world!"'
sh
'./jenkins/scripts/deploy-for-production.sh'
input
message:
'Finished using the web site? (Click "Proceed" to continue)'
sh
'./jenkins/scripts/kill.sh'
}
}
}
}
}
}
}
}
\ No newline at end of file
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