Hi Guys,

I need Some help loading external functions in Jenkinsfile.

Jenkinsfile contents below:
node('local-node')

{

git "https://github.com/afahd/MW.git";
echo "this is groovy"
clone.clone()

}

Externally loaded function:





@Grab(group='org.yaml', module='snakeyaml', version='1.17')
import org.yaml.snakeyaml.*
public class Dependency {
   public LinkedHashMap h1;
   Dependency(LinkedHashMap h1) {
       this.h1 = h1
   }
}
def clone()
{
  Yaml yaml = new Yaml();
  String project;
  String location;
  String branch;
  String build;
  InputStream input = new FileInputStream(new File("dependencies.yaml"));
  Dependency data = yaml.load(input);
  Set s1 = data.h1.keySet();
  for (int num=0;num<s1.size();num++)
  {
      project = s1.toArray()[num];
      location = data.h1.get(project)['location'];
      branch = data.h1.get(project)['branch'];
      build = data.h1.get(project)['build'];
      echo "Cloning dependencies for $project "
      git branch: branch, url: location
   }
}
return this;

When i call clone.clone() the function gets executed on the *master node 
not the 'local-node'. *

-- 
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/222f028c-90aa-4554-9ea4-db06c9ad86c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to