更改 Jenkins 构建名称 &JAVA API 描述 [英] Changing Jenkins Build Name & Description through API in JAVA
本文介绍了更改 Jenkins 构建名称 &JAVA API 描述的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 Java 通过 REST API 更改 Jenkins 的构建 # 和构建描述.我可以在下面的 URL 中看到,这些人试图使用一些 curl 代码更改构建描述,
I am trying to change the Jenkins's build # and build description through REST API using Java. I could see that in the below URL, this guys has tried to change the build description using some curl code,
我不知道他是如何通过 curl 命令实现的.请帮忙!
I have no idea how he is achieving it through curl commands. Please help!
http://localhost:8080/job/<BUILD_NAME>/<BUILD_NUMBER>/api/
推荐答案
我需要在 Perl(我是新手)中执行此操作,并获得以下对我有用的内容:
I needed to do this in Perl (which I'm new to) and got the following to work for me:
sub ChangeJobDescription {
my $url = 'http://jenkinurl/job/<job_name>/<job_number>/configSubmit';
my $jsonData = '{"displayName" => "<new Build title>", "description" => "<new Build description>"}';
my $ua = LWP::UserAgent->new();
my $req = POST($url,
Content_Type => 'application/x-www-form-urlencoded',
Content => [ 'Submit' => 'save', 'json' => $jsonData ],
);
$req->authorization_basic('user', 'password');
my $response = $ua->request($req);
print $response->as_string;
}
这篇关于更改 Jenkins 构建名称 &JAVA API 描述的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文