简体   繁体   English

Jenkins Groovy脚本-git命令执行

[英]Jenkins groovy script - git command execution

I've been trying to retrieve number of commits to use them as a number. 我一直在尝试检索提交数量以将它们用作数字。 The working command that i know of is: "git rev-list develop.. --count". 我知道的工作命令是:“ git rev-list development .. --count”。 Thats the number I try to get. 那就是我试图得到的数字。 I want to assign it to variable and use it in some other line to introduce version, so my lines in groovy look like this. 我想将其分配给变量并在其他行中使用它来引入版本,因此我在groovy中的行看起来像这样。 Assignment: 分配:

       def commitCount = "git rev-list develop.. --count".execute() 

Basically the Jenkins throws error at me that looks like this: 简而言之,詹金斯向我抛出了如下错误:

"Scripts not permitted to use staticMethod" “不允许脚本使用staticMethod”

Any ideas how to make it work? 有什么想法使它起作用吗?

尝试: def out = sh(script: 'rev-list develop.. --count', returnStdout: true).trim()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM