Plugin Agent/Sever Communication - Unidirectional


We have a custom plugin which we previously configured using XML-RPC which we now want to switch to unidirectional. The problem with this is that the agent requires some details from the server (server-side plugin) to authenticate with an downstream app which currently gets sent via XML-RPC from server to agent.

Is there a way for the server to allow registered agents to request these details?

Comment actions Permalink

Hi, you can register custom a controller ( that will provide the necessary data by HTTP. Then call the controller from the agent.  

Comment actions Permalink

We've already got a controller configured. How do you call it from agent side though?

Comment actions Permalink

Just send ordinary http requests using HttpClient instance obtained from the HttpUtil class.

Comment actions Permalink

I am getting error with 401 http status code. I added the my code below.  I require credentials which I don't know how to obtain. Do you have any idea. By the way thank your for support.

import jetbrains.buildServer.http.HttpUtil;

HttpClient httpClient = HttpUtil.createHttpClient(60);
PostMethod httpPost = new PostMethod(scanDataControllerURI.toString());
HttpClientParams httpClientParams = new HttpClientParams();
httpClientParams.setParameter(Scan_Task_ID_Literal, ScanTaskID);
httpClientParams.setParameter(BuildID_Literal, BuildID);
httpClientParams.setParameter(Message_Literal, Message);
httpClientParams.setParameter(Data_Literal, Data);
httpClientParams.setParameter(Is_Error_Literal, IsError);
httpClientParams.setParameter(HTTP_Status_Code_Literal, HTTPStatusCode);
Comment actions Permalink

You are getting 401 response because the Controller requires authorization.

If the Controller doesn't provide any secured data then you can omit the authentication using the following method:


Another way is to add some user credentials to the request, it depends on the controller logic. Could you share what is the controller responsible for?

Comment actions Permalink

Thank you for your response.

Controller will store scanresult data for viewlogtab by storing data to customdatastore. How can i find userid and password for basic form authentication.

//code form my controller.

Map<String, String> parameters = getParameters(httpServletRequest);
ScanRequestResult scanRequestResult = new ScanRequestResult(parameters);
//todo: test persistence with restarting server.
DataStorage storage=new DataStorage(server);
//Stores scanRequestResult for ScanLogTab. Now scan log tab can access scan report
ScanRequestResult validationMap = storage.GetScanRequestResult(scanRequestResult.BuildID);

//code from DataStorage

public DataStorage(SBuildServer server) {
this.server = server;

public void StoreScanRequestResult(ScanRequestResult scanRequestResult) {
final SBuild build = server.findBuildInstanceById(scanRequestResult.BuildID);
SBuildType buildType = build.getBuildType();
CustomDataStorage scanRequestStorage = buildType.getCustomDataStorage(ScanRequestStoragePrefix + scanRequestResult.BuildID);

public ScanRequestResult GetScanRequestResult(long buildID) {
final SBuild build = server.findBuildInstanceById(buildID);
SBuildType buildType = build.getBuildType();
CustomDataStorage scanRequestStorage = buildType.getCustomDataStorage(ScanRequestStoragePrefix + buildID);
ScanRequestResult scanRequestResult=new ScanRequestResult(scanRequestStorage.getValues());
return scanRequestResult;
Comment actions Permalink


you can create a special user with administration permissions for the build configuration and use his credentials for the Basic authentication. But please note that in this case credentials can be become publicly visible. 


Please sign in to leave a comment.