Accessing the current Jenkins build in Groovy script

后端 未结 3 2005
攒了一身酷
攒了一身酷 2021-02-14 06:09

I have created a Groovy script which is used in a System Groovy Script step in a Jenkins job which needs to access the current build of the current job.

T

3条回答
  •  忘掉有多难
    2021-02-14 06:30

    If in your Jenkins job you are using Groovy plug-in, then inside Execute system Groovy script step the plug-in already provides you access to some predefined variables:

    build
        The current AbstractBuild.
    launcher
        A Launcher.
    listener
        A BuildListener.
    out
        A PrintStream (listener.logger).
    

    For example:

    println build.getClass()
    

    Outputs:

    class hudson.model.FreeStyleBuild
    

提交回复
热议问题