How to use groovy script on jenkins

1. Install groovy plugin

2. Add a step of groovy. (normal & systerm)

3. Execute groovy script

import jenkins.model.*

def q = Jenkins.instance.queue

q.items.findAll{ it.task.name.startsWith(‘ttt‘) }.each{ q.cancel(it.task) }

Above script is cancel all pending build in queue.

Additional info:

install groovy :

GVM (the GroovyenVironment Manager)
This tool makesinstalling Groovy on any Bash platform (Mac OSX, Linux, Cygwin, Solaris orFreeBSD) very easy.

Simply open a newterminal and enter:

$ curl -s get.gvmtool.net | bash

Follow theinstructions on-screen to complete installation.

Open a newterminal or type the command:

$ source "$HOME/.gvm/bin/gvm-init.sh"

Then install thelatest stable Groovy:

$ gvm install groovy

After installationis complete and you‘ve made it your default version, test it with:

$ groovy -version

That‘s all thereis to it!

时间: 2024-08-08 10:53:25

How to use groovy script on jenkins的相关文章

SoapUI Pro Project Solution Collection –Easy develop Groovy Script to improve SoapUI ability

As you know the groovy script and java script language is the soapui supported .but unfortunately Soapui's groovy editor had not provided a better editor to write the groovy script. there are two approaches you can take to write your own groovy scrip

Common tasks that you can perform with the Groovy Script test step

https://support.smartbear.com/readyapi/docs/soapui/steps/groovy.html Get test case object To obtain the object which refers to the containing test case, use the following code snippet: Groovy def case = testRunner.testCase; By using the testCase obje

一个简单的groovy script生成的class文件及其反编译

Groovy def task = { println "Hello from source code-Task" } task() def task2 = { println "Hello from source code-Task2" } class B { String getName(){ return "Young" } } println new B().getName(); task2(); 结果 Hello from source

Elasticsearch的Groovy Script自定义评分检索

需求:以索引中的boostapp列作为评分的基础分值,同时根据carpublishtime(数据的刷新时间字段)按时间进行衰减. 基于Groovy脚本实现. 1.query脚本方式: { "fields": [ "boost", "ucarid", "boostapp", "carpublishtime" ], "query": { "function_score":

[Training Video - 5] [Groovy Script Test Step - Collections, Exceptions] Exception Handling in groovy

def x = new String[3] x[0] = "A" x[1] = "B" x[2] = "C" log.info"XXXXXX 1" try{ x[3] = "D" // def z=9/0 }catch(Exception e){ log.info "Some error "+e.getMessage() // Use e.getMessage() to print ex

Ready api groovy script 参数化

def token_type =context.expand ('${#Project#token_type}')def access_token = context.expand('${#Project#access_token}') def Authorization=token_type+" "+access_token//testRunner.testCase.setPropertyValue( token_type+" "+access_token, co

Jenkins <5> Test your Groovy scripte

Jenkins supports Groovy script very well, so you can use Groovy to do a lot of tricky and interesting things. First, if you have a Groovy script, and need to verify it if it works well in Jenkins, you can go toJenkins--> System management --> Script

Jenkins(二) 安装、新建Jobs与删除及SVN配置(转)

官网首页(https://jenkins-ci.org/)就提供了windows版本的Jenkins安装包.可以自己下载一个用于学习.安装后自动打开http://localhost:8080,就可以看见Jenkins的界面. 要运行Jenkins的其它配置: 1,Jenkins是java程序,因此需要安装JDK. 2,同时运行job需要提供repository,也就是存放Jenkins定期poll源代码的地方.可以去github免费注册一个. 3,如果想在Jenkins中使用ant,maven等

[原] Jenkins Android 自动打包配置(转)

一.Jenkins自动打包配置 目标:1. 自动打包:2. 自动上传:3. 友好下载 1. Jenkins简介 Jenkins是基于Java开发的一种持续集成工具,用于监控持续重复的工作. 减少重复劳动,减少人工成本. 持续.自动地构建/测试软件项目: 监控一些定时执行的任务: 2. Jenkins配置 添加git plugin和 role插件 设置人员权限,根据角色授权 启动访问http://ip/8080即可,见下3.1 开机自启脚本 添加git项目,配置脚本,见下3.2 项目打包脚本和3.