title: How to loop through Jenkins multi-line string parameter?
body: <p>I have app_name as a multi-line string parameter, I want to loop it through so I can create ingress objects for applications.</p>
  <p>I have defined them as below:
  <a href="https://i.stack.imgur.com/D2QOm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D2QOm.png" alt="app name as multi-line string parameter " /></a></p>
  <p>Now, my shell script snippet for the Jenkins file is like below:</p>
  <pre><code>echo &quot;${app_name}&quot;
              for i in &quot;${app_name}&quot;; do
                  kubectl delete ing ${i} -n${deployment_namespace}
                  cp -apvf  /tmp/flexicache-ing.yaml /tmp/flexicache-ing-${i}.yaml
                  pwd
                  sed -i 's/#{deployment_ns}#/'&quot;${deployment_namespace}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{app_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{chart_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  kubectl apply -f /tmp/flexicache-ing-${i}.yaml
              done
  </code></pre>
  <p>Output:</p>
  <pre><code>+ echo 'flexicache-data-processor
  flexicache-incident-data-processor'
  flexicache-data-processor
  flexicache-incident-data-processor
  ++ tput bold
  + bold=''
  ++ tput sgr0
  + normal=''
  + for i in '&quot;${app_name}&quot;'
  + kubectl delete ing flexicache-data-processor flexicache-incident-data-processor -nsit1-blue
  Error from server (NotFound): ingresses.extensions &quot;flexicache-data-processor&quot; not found
  Error from server (NotFound): ingresses.extensions &quot;flexicache-incident-data-processor&quot; not found
  + cp -apvf /tmp/flexicache-ing.yaml /tmp/flexicache-ing-flexicache-data-processor flexicache-incident-data-processor.yaml
  cp: target 'flexicache-incident-data-processor.yaml' is not a directory
  </code></pre>
  <p>I have tried it with an array as well but that seems to be not working as well.</p>
  <p>Need to understand what I am doing wrong.</p>
  <p>P.S: Changed the code to the below:</p>
  <pre><code>for i in ${app_name}; do
                  kubectl delete ing ${i} -n${deployment_namespace}
                  cp -apvf  /tmp/flexicache-ing.yaml /tmp/flexicache-ing-${i}.yaml
                  pwd
                  sed -i 's/#{deployment_ns}#/'&quot;${deployment_namespace}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{app_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{chart_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  kubectl apply -f /tmp/flexicache-ing-${i}.yaml
              done
  </code></pre>
  <p>Output is still busted:</p>
  <pre><code>+ sed -i 's/#{app_name}#/flexicache-data-processor
  flexicache-incident-data-processor/' /tmp/flexicache-ing-flexicache-data-processor.yaml
  sed: -e expression #1, char 40: unterminated `s' command
  </code></pre>
  <p>EDIT 2: I did used code of &lt;&lt;&lt; before bt still not woring.
  Code below:</p>
  <pre><code>            while IFS= read -r i; do
                  kubectl delete ing ${i} -n${deployment_namespace}
                  cp -apvf  /tmp/flexicache-ing.yaml /tmp/flexicache-ing-${i}.yaml
                  pwd
                  sed -i 's/#{deployment_ns}#/'&quot;${deployment_namespace}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{app_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  sed -i 's/#{chart_name}#/'&quot;${app_name}&quot;'/' /tmp/flexicache-ing-${i}.yaml
                  kubectl apply -f /tmp/flexicache-ing-${i}.yaml
              done &lt;&lt;&lt; &quot;${app_name}&quot;
  </code></pre>
  <p>Output with failed sed...</p>
  <pre><code>+ sed -i 's/#{chart_name}#/flexicache-data-processor
  flexicache-incident-data-processor/' /tmp/flexicache-ing-flexicache-data-processor.yaml
  sed: -e expression #1, char 42: unterminated `s' command
  </code></pre>
  <p>Please do not make the question &quot;duplicate&quot; if you have not fully understood the problem statement.</p>