How to retrieve Jenkins build parameters using the Groovy API?

前端 未结 10 2122
忘掉有多难
忘掉有多难 2020-12-09 07:55

I have a parameterized job that uses the Perforce plugin and would like to retrieve the build parameters/properties as well as the p4.change property that\'s set by the Perf

10条回答
  •  囚心锁ツ
    2020-12-09 08:21

    Get all of the parameters:

    System.getenv().each{
      println it
    }
    

    Or more sophisticated:

    def myvariables = getBinding().getVariables()
    for (v in myvariables) {
       echo "${v} " + myvariables.get(v)
    }
    

    You will need to disable "Use Groovy Sandbox" for both.

提交回复
热议问题