Jenkins官方文档网址:https://www.jenkins.io/zh/doc/
更多groovy写法请查看官网文档
一个测试的groovy流水线
int NUM01=45 int NUM02=19 String NAME="tom" int AGE=23 LISTS=[1, 2, 3, 4, 5] pipeline { agent{ label "java-node01" //指定slave运行 } stages { stage('test') { steps { script { //groovy脚本 def a = 55 def b = 45 println(a+b) NUM=NUM01+NUM02 println(NUM) for (i in LISTS){ println(i) if (i == 4){ LISTS.remove(3) } } println(LISTS) println(NAME) println(AGE) env.TEST = "test" //阶段变量 } } } stage('shelltest') { steps { sh """ echo "my is shell" sleep 5s """ } } stage('groovyttest') { steps { script { println("${env.TEST}") } } } } }