Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to call a function under my pipeline , the function name is CMList and the arguments eList and pLists are in the format of email address .


Python
def eList ="${emailAddress}"
def pLists = "${POEmailList}"




Below are the choice parameter added , so that the entries appear in the Jenkins UI and value needs to be input for both
eList and pLists .


Python
properties([
  parameters([
    text(description: 'Provide Email Address of the  PO ', name: 'POEmailList'),
    text(description: 'Provide Email Address of the people to be notified', name: 'emailAddress'),
    ])
])




Below snippet describes the function call:


Python
node(windowsNode) {
nslookup() 
CMList() // Calling CMList function under `windowsnode`. 
}



The function CMList is defined as below:


Python
void CMList(String eList,String pLists)
  stage('Generate Email List To Be Notified') {
      if(!((currentBuild.currentresult).contains('UNSTABLE'))){
          eList = eList + ";" + pLists
      }
      echo 'Notify to users - '+ eList
  }



I want to create a function as CMList that consists of a stage in groovy . But this function throws the error as

Python
'No such DSL method 'createEmailList' found among steps [ArtifactoryGradleBuild, MavenDescriptorStep, addBadge'....


What I have tried:

I tried not to mention the datatype in arguments of function and also tried not to use if conditional as start , rather I prepended `script{} ` block before if conditional but no luck

void CMList(String eList,String pLists)
  stage('Generate Email List To Be Notified') {
      if(!((currentBuild.currentresult).contains('UNSTABLE'))){
          eList = eList + ";" + pLists
      }
      echo 'Notify to users - '+ eList
  }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900