Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
global-jenkinsfile
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QA
global-jenkinsfile
Commits
4ab09fe5
Commit
4ab09fe5
authored
Dec 05, 2017
by
daidekun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加数组分隔方法
parent
6cd795ee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
15 deletions
+4
-15
qgAnsiblePipeline.groovy
vars/qgAnsiblePipeline.groovy
+4
-15
No files found.
vars/qgAnsiblePipeline.groovy
View file @
4ab09fe5
import
org.qg.ansible.*
def
call
(
body
)
{
...
...
@@ -12,24 +13,12 @@ def call(body) {
def
dataCenter
=
env
.
data_center
def
machines
=
env
.
hosts
def
_utils
=
new
org
.
qg
.
ansible
.
Utils
()
body
.
resolveStrategy
=
Closure
.
DELEGATE_FIRST
body
.
delegate
=
config
body
()
def
partition
(
array
,
size
)
{
def
partitions
=
[]
int
partitionCount
=
array
.
size
()
/
size
partitionCount
.
times
{
partitionNumber
->
def
start
=
partitionNumber
*
size
def
end
=
start
+
size
-
1
partitions
<<
array
[
start
..
end
]
}
if
(
array
.
size
()
%
size
)
partitions
<<
array
[
partitionCount
*
size
..-
1
]
return
partitions
}
node
{
stage
(
'Clean'
)
{
deleteDir
()
...
...
@@ -43,7 +32,7 @@ def call(body) {
stage
(
'Deploy'
)
{
arr_machines
=
machines
.
split
(
","
)
machines_list
=
partition
(
arr_machines
,
1
)
machines_list
=
_utils
.
partition
(
arr_machines
,
1
)
echo
machines_list
sh
"ansible-playbook /etc/ansible/nginx_remove.yml -e project_name=${envType}.${projectName} -e data_center=${dataCenter} -e machines=${machines} -vv"
...
...
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