Update the values of system properties before VCS is fetched.
Hello,
I want to update the system properties of the project before it fetches the VCS. In the following image, I want to update %my_custom_variable% and replace it with other value before the server fetches and VCS and pass it to the agent.
I have checked the following method under BuildStartContextProcessor interface, but it can only update parameters after VCS is fetched and before it is started on a build agent.
void updateParameters(@NotNull BuildStartContext context)
I can be able to capture the event before the server fetches the VCS with buildStarted method of BuildServerAdapter. Please check the following code. But I still couldn't find any method to update the parameters. May I know if team city provides the API on what I'm trying to achieve? Can someone please guide me on this?
public class CustomServerAdaptor extends BuildServerAdapter {
public EventDispatcher<BuildServerListener> dispatcher;
public SSLTrustStoreProvider trustStoreProvider;
public CustomServerAdaptor(EventDispatcher<BuildServerListener> dispatcher, SSLTrustStoreProvider trustStoreProvider){
this.dispatcher = dispatcher;
this.trustStoreProvider = trustStoreProvider;
this.dispatcher.addListener(this);
}
@Override
public void buildStarted(SRunningBuild build){
Logger logger = Loggers.SERVER;
logger.info("logging from build server adaptor");
Map<String, String> properties = build.getBuildOwnParameters();
// Here I can get the value of my property. But I couldn't update my property to the new value
for (Map.Entry<String, String> kv : properties.entrySet() ) {
logger.info("-----logging for params-------");
logger.info(kv.getKey()+":"+kv.getValue());
}
}
}
Please sign in to leave a comment.