snippetMinor
How to read array and loop server selection and deployment
Viewed 0 times
selectionreadarrayserverloophowanddeployment
Problem
I have configured jenkins parameter deployment job using active choices parameterize plugin. In my dev server section have two servers called, 192.168.94.139, 192.168.94.140
I want to read this array input and deploy to both servers. As an example if I select both servers artifacts should be deployed to both servers. How can I read those inputs to fulfill my requirement. Until this point I wrote an array to read inputs but it prints like this
192.168.94.139,192.168.94.140
I want to read this array input and deploy to both servers. As an example if I select both servers artifacts should be deployed to both servers. How can I read those inputs to fulfill my requirement. Until this point I wrote an array to read inputs but it prints like this
192.168.94.139,192.168.94.140
my_array=($SERVER_SELECTION)
for i in ${my_array[@]}
do
echo $my_array
doneSolution
Look this:
I found this link
#!/bin/bash
#Get servers list
set -f
string=$DEPLOY_SERVER
array=(${string//,/ })
for i in "${!array[@]}"do
echo "Deploy project on server ${array[i]}"
doneI found this link
Code Snippets
#!/bin/bash
#Get servers list
set -f
string=$DEPLOY_SERVER
array=(${string//,/ })
for i in "${!array[@]}"do
echo "Deploy project on server ${array[i]}"
doneContext
StackExchange DevOps Q#5620, answer score: 2
Revisions (0)
No revisions yet.