Set the pipeline name and description from Jenkinsfile

前端 未结 3 1547
清酒与你
清酒与你 2021-02-12 14:32

I am trying to do a poc of jenkins pipeline as code. I am using the Github organization folder plugin to scan Github orgs and create jobs per branch. Is there a way to explicitl

3条回答
  •  走了就别回头了
    2021-02-12 15:16

    I tried to used code snippet from accepted answer to describe my Jenkins pipeline in Jenkinsfile. I had to wrap code snippet into function with @NonCPS annotation and use def for item variable. I have placed code snippet in root of Jenkinsfile, not in node section.

    @NonCPS 
    def setDescription() { 
        def item = Jenkins.instance.getItemByFullName(env.JOB_NAME) 
        item.setDescription("Some description.") 
        item.save()
    }
    
    setDescription()
    

提交回复
热议问题