Thanks, ".substring(16)" did the trick for what I needed in addition to the 
variables suggestion.

On Sunday, June 25, 2017 at 3:25:06 PM UTC+3, slide wrote:
>
> Groovy will not replace anything if you use single quotes. The problem is 
> that you are mixing shell variables and groovy variables, so you need to be 
> careful. Try something like this:
>
> datacenter=repoName.substring(0, 16)
>  sh """
>                            export 
> KUBECONFIG=/home/bluemix/.bluemix/plugins/container-service/clusters/${clusterName}/kube-config-${datacenter}-${clusterName}.yml
>                         
>                            # Set the build number
>                            case ${repoName} in
>                               "****") 
>                                  ../../../yaml w -i 
> config/environments/prod/$clusterName/kubernetes/deployment.yaml 
> spec.template.spec.containers[0].image 
> registry.ng.bluemix.net/certmgmt_prod/instmgr:$instmgr
>                                  ;;
>                            esac
>                          """
>
> On Sun, Jun 25, 2017 at 12:50 AM Idan Adar <[email protected] <javascript:>> 
> wrote:
>
>> I'm having difficulty passing parameters into a multiple lines sh section 
>> like below.
>> Can someone help with spotting the problem?
>>
>> Specifically, 
>> 1. $datacenter is empty
>> 2. $clusterName is empty
>> 3. I suspect $repoName is empty too
>>
>>
>> stage ("Update Deployments") {      
>>          steps {
>>             script {
>>                def repoList = microServicesToPublish.tokenize(",")
>>                def clusterList = clustersToPublishTo.tokenize(",")
>>                
>>                for (String clusterName : clusterList) {
>>                   for (String repoName : repoList) {
>>                      
>>                      // Create a folder based on the current repository 
>> in the list
>>                      dir(repoName) {
>>                         // Clone it
>>                         git branch: 'master', credentialsId: 
>> 'caf2691d-42c7-4d10-acf0-cf5fcc2575a4', url: "https://****/****/"; + 
>> repoName
>>                         
>>                         // Apply Kubernetes configuration and update the 
>> Deployment
>>                         sh '''
>>                            datacenter=${repoName:16}
>>                            export 
>> KUBECONFIG=/home/bluemix/.bluemix/plugins/container-service/clusters/$clusterName/kube-config-$datacenter-$clusterName.yml
>>                         
>>                            # Set the build number
>>                            case $repoName in
>>                               "****") 
>>                                  ../../../yaml w -i 
>> config/environments/prod/$clusterName/kubernetes/deployment.yaml 
>> spec.template.spec.containers[0].image 
>> registry.ng.bluemix.net/certmgmt_prod/instmgr:$instmgr
>>                                  ;;
>>                            esac
>>                          '''
>>                       }
>>                   }
>>                }
>>             }
>>        }          
>>  }
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Jenkins Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/a20604e6-42cf-452d-887f-c4d3ab58bc69%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/a20604e6-42cf-452d-887f-c4d3ab58bc69%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/832c7248-f6eb-4467-95b9-c7ebba9838e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to