[Request Bitbucket Pipeline] Switch Environmental Variable values based on Branch

Issue #18269 closed
Alex Wong
created an issue

Hi there,

I have a request regarding Bitbucket Pipelines.

If I push to branch-A, I want to run tests using branch-A envs.

If I push to branch-B, I want to run tests using branch-B envs.

I have tried the following but it would revert the env to whatever env I set from the Repository Envs.

Test

Prerequisite

  • Repository Env already has MY_ENV=hello

branch A

  • step1: MY_ENV=world

  • step2: echo $MY_ENV (result: hello)

Conclusion

Basically on a new step, whatever ENV I set in the previous step gets reset. I will create an issue in the public issue tracker.

Right now what I am doing is creating duplicate steps that all do the same thing (build, test) but just changes the ENV in the beginning, which isn't a huge issue. It just would be nice to be able to reuse steps instead and just switch out the env.

Comments (3)

  1. Aneita Yang staff

    Hi @Alex Wong,

    Thanks for reaching out and for the suggestion.

    We're currently working on supporting parameterized builds in Pipelines (issue #13737), which will let you define variables required for a pipeline to run, at the point at which the pipeline is triggered. At this point in time, only custom pipelines can be configured to require these variables. This might be something that you can leverage once it's available, by configuring your pipelines as custom pipelines, and defining the variables that need to be inputted in order for the build to run successfully. Here's a screenshot which might give you a better idea for what this feature is:

    variables.png

    Let me know if this is something that suits your use case.

    Aneita

  2. Aneita Yang staff

    Hey Alex,

    I'm going to close this issue for now given the lack of a response. Please feel free to reopen this ticket if it's something that you're still interested in.

    Thanks,
    Aneita

  3. Log in to comment