1

I have a Jenkins parent groovy file which consumes the child groovy file

Parent grooy file:

...
def child = load 'child-groovy-file';
child.execute();

Child groovy file:

a = "first letter";
b = "second letter;
def execute
{
echo "a is "+a;
...
}

But this is not working. Unable to access variables, which are defined in Child Groovy file, when trying to access from Parent groovy file. When I create a node block and trying to consume directly the child groovy file, It is working.

Is the Environment variables only the solution to access globally?

0

try this one

static void main(String[] args) { 
      // Initializing 2 variables 
      def x = 5; 
      def y = 10;

      //Performing addition of 2 operands 
      println(x+y);
 }

}

check this URL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.