Skip to content
  • Groovy 代码调试窗口

Jenkins -> Manage Jenkins ->Script Console 是一个非常好的Groovy 代码调试窗口

jenkins script console 的官方文档:

https://www.jenkins.io/doc/book/managing/script-console/

1.groovy 打印log

jenkins job 配置Groovy postbuild, 打印日志的方法:

manager.listener.logger.println("Complete build with skip")
jenkins job 配置Groovy postbuild, 打印日志的方法:

manager.listener.logger.println("Complete build with skip")

2.开源库

https://github.com/cloudbees/jenkins-scripts

https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler

https://github.com/tkrzeminski/jenkins-groovy-scripts

https://github.com/politie/pipeline-library

https://github.com/funkwerk/jenkins-workflow
https://github.com/cloudbees/jenkins-scripts

https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler

https://github.com/tkrzeminski/jenkins-groovy-scripts

https://github.com/politie/pipeline-library

https://github.com/funkwerk/jenkins-workflow

3.修改build状态

Groovy postbuild插件

import hudson.model.Result
String desc = "Build Skipped"<br>def build=Thread.currentThread().executable
manager.build.setDescription(desc)
manager.build.@result = hudson.model.Result.UNSTABLE
Groovy postbuild插件

import hudson.model.Result
String desc = "Build Skipped"<br>def build=Thread.currentThread().executable
manager.build.setDescription(desc)
manager.build.@result = hudson.model.Result.UNSTABLE

4.语法

https://blog.csdn.net/yanbober/article/details/49047515?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164671794816780269850607%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fall.%2522%257D&request_id=164671794816780269850607&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~first_rank_ecpm_v1~rank_v31_ecpm-2-49047515.pc_search_result_cache&utm_term=Groovy&spm=1018.2226.3001.4187