Set the pipeline name and description from Jenkinsfile

前端 未结 3 1530
清酒与你
清酒与你 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:12

    You need to use currentBuild like below. The node part is important

    node {
        currentBuild.displayName = "$yournamevariable-$another"
        currentBuild.description = "$yourdescriptionvariable-$another"
    }
    

    Edit: Above one renames build where as Original question is about renaming jobs. Following script in pipeline will do that(this requires appropriate permissions)

    item = Jenkins.instance.getItemByFullName("originalJobName")
    item.setDescription("This description was changed by script")
    item.save()
    item.renameTo("newJobName")
    

提交回复
热议问题