Running Groovy command from Jenkins using Groovy script plugin

后端 未结 3 530
隐瞒了意图╮
隐瞒了意图╮ 2020-12-10 03:43

I want to force following scenario in Jenkins:

  1. I have job A and job B
  2. I want to disable job A when job B is executed, and after execution of job B, I
3条回答
  •  一生所求
    2020-12-10 04:13

    I ran into the same problem "unable to resolve class jenkins.model.Jenkins" as commented by @iloveretards, until I realized I had tried to use the build step "Execute Groovy script". After switching to build step "Execute system Groovy script", this actually worked as intended:

    import jenkins.model.Jenkins
    Jenkins.instance.getItem("job-name").disable()
    

提交回复
热议问题