Hm, failed with the same error... full stack: https://pastebin.com/AL2J5MMS


On Tuesday, August 8, 2017 at 9:49:28 AM UTC+3, mpapo - Michael Pailloncy 
wrote:
>
> The for loop is in Java syntax instead of script shell syntax here :
>
> sh """
>     git clone -b master git@****.com:****/${repoName}.git
>     cd ${repoName}
>        
>     stat -t . > folderStat1.txt
>     for (String moduleName : moduleList) {
>        ncu -u -f "${moduleName}"
>     }
>     
>     stat -t . > folderStat2.txt
> """
>
> IIUC, you want to do something like :
>
> sh "git clone -b master git@****.com:****/${repoName}.git"
>
> dir(repoName) {
>     sh "stat -t . > folderStat1.txt"
>     for (int i = 0; i < moduleList.size(); i++) {
>         def moduleName = moduleList[i]
>         sh "ncu -u -f \"${moduleName}\""
>     }
>     sh "stat -t . > folderStat2.txt"
> }
>
> Hopefully it helps.
>
> 2017-08-07 14:49 GMT+02:00 Idan Adar <[email protected] <javascript:>>:
>
>> I have tried this, but it complains: 
>>
>> groovy.lang.MissingPropertyException: No such property: moduleName for 
>> class: WorkflowScript
>>
>>
>> Here is the full Jenkinsfile:
>> The majority of it can be disregarded... the issue at hand is the use of 
>> the variables, ${repoName}, ${moduleName}, etc...
>>
>> ReposToUpdate and npmDependencies are Extended choice parameters e.g.:
>> myrepo1,myrepo2,myrepo3,...
>>
>> def repoList = ReposToUpdate.tokenize(",");
>> def moduleList = npmDependencies.tokenize(",");
>>
>> pipeline {
>>    agent {
>>       label 'cert_mgmt' 
>>    }
>>
>>    stages {
>>       stage ("Update package.json") {
>>          steps {
>>             script {
>>                for (String repoName : repoList) {
>>                   sshagent (credentials: ['credentials-ID']) {
>>                      sh """
>>                         git clone -b master 
>> git@****.com:****/${repoName}.git
>>                         cd ${repoName}
>>                            
>>                         stat -t . > folderStat1.txt
>>                         for (String moduleName : moduleList) {
>>                            ncu -u -f "${moduleName}"
>>                         }
>>                         
>>                         stat -t . > folderStat2.txt
>>                      """
>>                      
>>                      def folderStat1 = readFile('folderStat1.txt').trim()
>>                      def folderStat2 = readFile('folderStat2.txt').trim()
>>                      
>>                      if (folderStat1 == folderStat2) {
>>                         slackSend (
>>                            color: '#199515',
>>                            message: "$JOB_NAME: <$BUILD_URL|Build 
>> #$BUILD_NUMBER> ${repoName}: Common code dependencies match the latest 
>> package versions."
>>                         )
>>                      }
>>                      else {
>>                         sh """
>>                            cd ${repoName}
>>                            
>>                            git config --global user.name "****"
>>                            git config --global user.email ****
>>                            git commit -am 'Bump common packages version 
>> number [ci skip]'
>>                            git push origin master
>>                         
>>                            cd ..
>>                            rm -rf ${repoName}
>>                         """
>>                         
>>                         slackSend (
>>                            color: '#199515',
>>                            message: "$JOB_NAME: <$BUILD_URL|Build 
>> #$BUILD_NUMBER> ${repoName}: Common code dependencies successfully updated 
>> to the latest package versions."
>>                         )
>>                      }
>>                   }
>>                }
>>             }
>>          }
>>       }
>>    }
>>    
>>    post {
>>       failure {
>>          slackSend (
>>             color: '#F01717',
>>             message: "$JOB_NAME: <$BUILD_URL|Build #$BUILD_NUMBER>, 
>> Update failed. Review the build logs."
>>          )
>>       }
>>    }
>> }
>>
>>
>>
>> On Sunday, July 30, 2017 at 10:48:39 PM UTC+3, Joachim Nilsson wrote:
>>>
>>> As I understand, it is written in Groovy. That means you can access a 
>>> variable in a (Groovy)string using dollar and optionally curly brackets. 
>>>
>>> "  variable value is ${variable} "
>>>
>>> Skaffa Outlook för Android <https://aka.ms/ghei36>
>>>
>>>
>>>
>>> Från: Idan Adar
>>> Skickat: söndag 30 juli 13:56
>>> Ämne: Accessing a variable in shell
>>> Till: Jenkins Users
>>>
>>>
>>> Given the following script block in a stage (Declarative pipeline), how 
>>> can I access the repoName variable?
>>>
>>> stages {
>>>     stage("...") {
>>>         script {
>>>             for (String repoName: repoList) {
>>>                 sshagent (credentials: 
>>> ['e276113e-0ec9-4eaa-88f9-a7db5c9635b6']) {
>>>                     sh """
>>>                         git clone -b master 
>>> git@****.com:****/repoName.git
>>>                         cd repoName
>>>                         ....
>>>                     """
>>>                 }
>>>             }
>>>          }
>>>      }
>>> }
>>>
>>> -- 
>>> 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/d9d247a5-8ab9-4154-99c5-8c77b0861ec2%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/jenkinsci-users/d9d247a5-8ab9-4154-99c5-8c77b0861ec2%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] <javascript:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/f5ba050e-2d42-47d4-8183-89e43edc6fec%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/jenkinsci-users/f5ba050e-2d42-47d4-8183-89e43edc6fec%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/afd21250-1d83-4f7f-a0fb-a1e97cec0298%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to