BuildStartContextProcessor prerequisites build feature

Hello,

When BuildStartContextProcessor is used to add some build parameters, some TeamCity Build Feature could be as prerequisites.

e.g.: If you want check/analyse the teamcity.pullRequest.number, the Pull Requests feature should (be logically enabled and) has been "executed".

 

By default, all build features seems not previously executed before the BuildStartContextProcessor (details JetBrains/TeamCity.SonarQubePlugin #89).

Is there a way to add this "kind of prerequisites" (Build feature execution) before the BuildStartContextProcessor execution ?


Another approach could be to use ParametersPreprocessor extension (teamcity.pullRequest.xxx are available in this case), but it is executed multiple times (the number of build steps, see #82 for details).

Is there a elegant way in this case to limit the number of execution to once only ?

Many thanks
Best regards

2 comments
Comment actions Permalink
Official comment

Yes, we have the PositionAware interface, which can be used to set sort of "dependencies" between extensions. There are 2 methods:

PositionConstraint getConstraint()

- this method should return desired constraint, which can be: PositionConstraint.first() (extension will be executed before others; all FIRST extensions will be executed in random order), PositionConstraint.last() (same rules as for FIRST), PositionConstraint.UNDEFINED (no exact ordering applied), PositionConstraint.before(String id) (will be executed before selected extension), PositionConstraint.after(String id) and PositionConstraint.between(Collection<String> afterIds, Collection<String> beforeIds)

String getOrderId();

- this method should return an ID which can be used by other extensions to reference in before(), after() and between() methods. If an extension doesn't provide an ID (like for Pull Requests feature), the fully qualified class name can be used in some cases. 

 

For your case you can use either PositionConstraint.last() or try to use PositionConstraint.after("jetbrains.buildServer.pullRequests.impl.PullRequestParametersProcessor"). PositionConstraint.last() will keep working even if referenced class will be renamed, so can be preferable. 

Comment actions Permalink

Hi Andrey,

Many many many thanks for this (very complete) answer.
It is working like a charm :-p.

Best regards

0

Please sign in to leave a comment.