Improved control over variables in multi-project pipelines
Problem to solve
Currently all the variables defined in a pipeline are passed to the downstream project when using the trigger:
. This is not always the desirable behavior and does not follow the idea of separation of concerns. By exposing the variable implicitly to the downstream project, we are blurring the line between the different pipelines and responsibilities. Right now, either the downstream pipeline must have information about the upstream project or vice versa in order to avoid naming conflicts. To make the pipelines reusable, shareable, robust and maintainable, there should be an API contract to fulfill ie. the variables should be considered as parameters that are passed in a "call" just like with functions/methods. Current way is fragile, harder to maintain and harder to debug. Additionally the current documentation is somewhat misleading, failing to mention anything about the fact that in addition to the job variables, the pipeline variables are passed to the downstream project as well.
Intended users
- Developers
- CI/CD maintainers
Further details
An example use case:
In upstream project we are building the application and create a docker image of it. The pipeline is generic for multiple applications and the application projects/repositories define the image name (nothing the downstream project should know of). At the end of the pipeline another pipeline (that does not contribute to the success of the build pipeline) is triggered and that should create documentation image. Both pipelines define DOCKER_IMAGE_NAME
variable, each has its own value.
Current behavior: The upstream project's variable writes over the downstream project's variable, causing a image to be built with wrong content.
Expected behavior: Only the variables defined for the trigger job should be passed OR the trigger job defines what is passed to the downstream. In this example case, nothing should be passed to the triggered pipeline.
Proposal
Allow the user to explicitly state what variables are to be passed down to the downstream project and only expose those.
Allow the user to prevent the automatic variable exposing.
What is the type of buyer?
The tier of the trigger:
feature (silver I believe)
Links / references
~feature