0

I have written a shared library in groovy which is being used by many other Jenkins Declarative jobs. Those jobs use this shared library function and pass in the required values which then will be loaded into the shared library when the function runs.

Here the variable is APP_NAME which should be passed by the user and then which will be loaded into a shared library function.

  1. New_APP="${APP_NAME} This doesn’t work and returns null
  2. New_APP=this.APP_NAME This works

Actually, both should work since it's groovy but the only second case seems to work. Any ideas why?

Kreddy
  • 11
  • 1
  • 4

1 Answers1

0

It really depends on how you consume use your shared library. For example, here is how I use my shared library

@Library('flowci') _
  io.k8s.flow.FlowPipeline.builder(this, 'flowci', label)

            .buildDefaultPipeline()

            .execute()

}

As you can see I pass parameters such as This and label, I don't have any issues. The context is saved on this, and I can access all Jenkins plugins abilities from there

Chen
  • 195
  • 1
  • 8