Changing Jenkins Build Name & Description through API in JAVA

前端 未结 3 984
北荒
北荒 2020-12-21 22:01

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 de

3条回答
  •  佛祖请我去吃肉
    2020-12-21 22:37

    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///configSubmit';
        my $jsonData = '{"displayName" => "", "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;
    }
    

提交回复
热议问题