please note that in declarative pipeline, all variables defined with *def* cannot be accessed by any method defined in the same script, they can only be accesed directly inside the pipeline {} block, if you need to define variables and use them in methods, you will have to define them as global i.e. without *def* or annotate them with *@Field* annotations to declare them as script class members.
@rakeshjha52 жыл бұрын
Simple and easy way to Learn Jenkins... Thanks for sharing 😊
@donvj0079 ай бұрын
we can use env.variable as well. Using this we can define a variable anywhere in pipeline and use them in upcoming stages
@hisnamewasjaan4 ай бұрын
those are not mutable though
@ArchitBohra Жыл бұрын
Thanks, I was looking for this exact thing.
@jawa1342 жыл бұрын
Very helpful thanks
@tinnu.universe2 жыл бұрын
What I did was I declared a variable def animal = my script' and assigned it to a global environment variable so that I can use in other stages. env.ANIMAL = animal