how can i define env to specific branches ?
Hi
how can i devine a env var to a specific branch?
eg.
i have a maven deployment step with this params:
-DskipTest -DTOKEN=%env.ACCESS_TOKEN% -DCONTEXT=%env.CONTEXT% -DTARGET_ENV=%env.TARGET_ENV_DEV% -DJELASTIC_API_ENDPOINT=%env.JELASTIC_API_ENDPOINT%
and i have to decide on runtime if i need the TARGET_ENV_DEV / TARGET_ENV_INT or TARGET_ENV_PROD
and add it automaticaly to the args list
the idea is if i have a PR from feat/branch -> Develop it should use TARGET_ENV_DEV to deploy to dev
if its a PR from * to release/branch then it should deploy to INT
and if * PR to master it should deploy to PROD
is this possible?
if yes how ?
best regards
Zafer
Please sign in to leave a comment.
1. Add build a build configuration parameter with name
env.TARGET_ENVIRONMENTand value%env.TARGET_ENVIRONMENT%.2. Build step 1 (Command Line). Custom script:
#!/bin/bash BRANCH=%teamcity.build.branch% if [[ $BRANCH == "develop" ]]; then echo "##teamcity[setParameter name='env.TARGET_ENVIRONMENT' value='TARGET_ENV_DEV']" elif [[ $BRANCH == "release" ]]; then echo "##teamcity[setParameter name='env.TARGET_ENVIRONMENT' value='TARGET_ENV_INT']" fi