Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surprises in branchToEnvironmentMapping #975

Open
filex opened this issue Feb 20, 2023 · 0 comments
Open

Surprises in branchToEnvironmentMapping #975

filex opened this issue Feb 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@filex
Copy link

filex commented Feb 20, 2023

Describe the bug

We have a fairly regular branch-mapping configured in our ODS 4.x project:

odsComponentPipeline(
  branchToEnvironmentMapping: [
    'develop': 'dev',
    'test': 'test',
    'eval': 'eval'
  ]
) { context ->
…

It "looks" like I had configured a simple 1:1 branch mapping.

But when I push a branch called develop-foobar two things happen:

  1. odsComponentStageBuildOpenShiftImage does not build the image:
Skipping stage 'Build OpenShift Image (diseasemap-couper)' for branch 'develop-update' as it is not covered by: 'develop', 'test', 'eval'.

(That is expected).

  1. odsComponentStageRolloutOpenShiftDeployment tries to rollout:
[Deploy to OpenShift-diseasemap] **** STARTING stage 'Deploy to OpenShift' for component 'diseasemap' branch 'develop-foobar' ****

That was unexpected.

Expected behavior

  1. Both functions must make the same decision (either run or don't)

  2. Both should decide against running because my branch map didn't indicate that I want "starts with" matches.

The second expectation is about the principle of least surprise.

This example is a bit more exciting:

  branchToEnvironmentMapping: [
    'develop': 'dev',
    'test': 'test',
    'feature/': 'dev'
  ]

The feature/ prefix contains a stop-character, which conveys gives the impression that multiple branches could be mapped.

setMostSpecificEnvironment looks like this may be a feature. So the testing-more-edge-cases branch would not trigger the test-env run but test-more-edge-cases would? That is surprising to me :)

Proposed Solution

Put aside any discussions about compatibility, we could change to only trigger the startsWith match if the key ends with an asterisk:

  branchToEnvironmentMapping: [
    'develop': 'dev',
    'test*': 'test',
    'feature/*': 'dev'
  ]

If key ends with * then remove * and go into if startsWith branch.

This would run test, testing-more and test-more, develop, feature/ and feature/foo but NOT develop-more and feature.

Affected version (please complete the following information):

  • OpenDevStack 4.x
@filex filex added the bug Something isn't working label Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant