In jenkins job, create file using system groovy in current workspace

前端 未结 4 625
鱼传尺愫
鱼传尺愫 2020-12-08 10:41

my task is to collect node details and list them in certail format. I need to write data to a file and save it as csv file and attach it as artifacts. But i am not able to c

4条回答
  •  半阙折子戏
    2020-12-08 11:08

    Answer by @Larry Cai covers one part to write a file to slave node from System Groovy Script (as it runs on Master Node).

    The part I am answering is "Some time i see people use "manager" object, how can i get access to it " This is the object already available in Post Build Groovy Script for accessing a lot of things like environment variables, Build Status, Build Display Name etc.

    Quoted from https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin :

    "The groovy script can use the variable manager, which provides various methods to decorate your builds. Those methods can be classified into whitelisted methods and non-whitelisted methods."

    To access it, we can directly call it in the post build groovy script. e.g

    manager.build.setDescription("custom description") manager.addShortText("add your message here")

    All methods available on manager objects are documented here.

    https://wiki.jenkins-ci.org/display/JENKINS/Groovy+Postbuild+Plugin#GroovyPostbuildPlugin-Whitelistedmethods

提交回复
热议问题