Get BuildFeature parameter from BuildServerAdapter

Hi Guys,

I have build feature with parameter and this parameter processed by BuildFeature:describeParameters as well (I can see this value on Build Steps page).

public String describeParameters(@NotNull final Map<String, String> params) {      StringBuilder result = new StringBuilder();      result.append("Debug: '"+params.get(Util.PUBLISH_PATH)+"'");
     return  result.toString();
}




I can acces to this parameter on agent side

  public void afterAtrifactsPublished(@NotNull                                         AgentRunningBuild runningBuild,                                         @NotNull                                         BuildFinishedStatus status){       String param = runningBuild.getBuildFeaturesOfType(Util.TYPE).iterator().next().getParameters().get(Util.PUBLISH_PATH));
      Loggers.AGENT.info(param);   }



But when I try to get it on server side I always have a null.

public void buildFinished(SRunningBuild build) {       String param2 = build.getBuildOwnParameters().get(Util.PUBLISH_PATH);       String publishPath = build.getParametersProvider().get(Util.PUBLISH_PATH);       String agentpublishPath = build.getAgent().getBuildParameters().get(Util.PUBLISH_PATH);       Loggers.SERVER.info("Publish to:"+publishPath+ " old value:"+param2+" agent value:"+agentpublishPath);

}


Could you help me to solve this?

Thank you.
8 comments
Comment actions Permalink

Hi Eduard,

For the time being the paramters of the build features are not saved with the build. That is, you can read the current values from the buildType settings, but there is not automatic way to get the parameters actual for the moment of the build start.
Agent API has access to the feature parameters, but again, they are not saved into the build on the server.

The current viable approach here is to save the necessary feature paramters into the build configuraiton parameters on build start. e.g. witht he help of BuildParamersProvider or ParametersPreprocessor.

Out of curiosity, what kind of build feature are you implementing? Do you plan to make it public?

0
Comment actions Permalink

Thank you for your answer.
I am going to add ability to publish build artifacts to net share. And I think would be better (IMHO) to do it from server side instead of agent side.

And I think it will be public.

0
Comment actions Permalink

Eduard,

> And I think would be better (IMHO) to do it from server side instead of agent side.

It's up to you as it's your plugin :)
From our standpoint, everything which can be done on the agent side, should be done there to reduce CPU/traffic load on the server.

0
Comment actions Permalink

I thought about it. But you will need to have permissions for net share for all agents instead of one server.

0
Comment actions Permalink

Could you explain your idea with saving feature parameter on start?

I can't understand how I can access to feature parameters from SRunningBuild or SBuildServer in BuildServerAdapter.

And one more question how I can get BuildArtifacts on agent side like server side ([SRunningBuild].getArtifacts(BuildArtifactsViewMode.VIEW_DEFAULT))? On agent side I see only getArtifactsPaths method in AgentRunningBuild.

Thank you.

0
Comment actions Permalink

Eduard,

> Could you explain your idea with saving feature parameter on start?
You can implement BuildParametersProvider.getParameters and use code like build.getBuildType().getBuildFeatures() to get the list of features, then find yours in the list and return a map with paramters which you need to use later.
Later you will be able to retrieve the paramters via SBuild.getParametersProvider()

> how I can get BuildArtifacts on agent side

You can try to implement interface ArtifactsPublisher and define it in the Spring configuration  - this way your agent plugin will receive events about every file that is published. However, you should not modify the files anyhow and the events can arrive after the build already finished it's execution, so it's use is limited.

0

Please sign in to leave a comment.