Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to use override values?

김주희 November 1, 2023

I will use the two steps for 'mainnet-detach', 'mainnet-attach' twice in pipelines.custom.

In the same code(mainnet-detach / mainnet-attach), when the "deploy-mainnet" step is executed for the first time, the variable 'instance_target' is defined as API01, and when the step is executed the second time, the variable 'instance_target' is defined and executed as API02.

 

How should I modify my code to set the variables?

[i need override values]

 

definitions:

services:

docker:

memory: 4096


###### deploy Mainnet ######

mainnet-detach: &mainnet-detach

step:

name: Detach mainnet ${target_instance}

image: amazon/aws-cli

runs-on:

- self.hosted

- linux

- ${target_instance}

oidc: true

script:

- export AWS_REGION=${AWS_REGION}

- export AWS_ROLE_ARN=${AWS_ROLE_ARN}

- export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token

- echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token

- aws sts assume-role-with-web-identity --role-arn ${AWS_ROLE_ARN} --role-session-name admin --web-identity-token "$BITBUCKET_STEP_OIDC_TOKEN" --duration-seconds 1000

- status=$(aws elbv2 describe-target-health --target-group-arn ${TARGET_GROUP_ARN} --targets Id=${target_instance_id} --query 'TargetHealthDescriptions[0].TargetHealth.State' --output text)


mainnet-attach
: &mainnet-attach

step:

name: Attach mainnet ${target_instance}

image: amazon/aws-cli

runs-on:

- self.hosted

- linux

- ${target_instance}

oidc: true

script:

- export AWS_REGION=${AWS_REGION}

- export AWS_ROLE_ARN=${AWS_ROLE_ARN}

- export AWS_WEB_IDENTITY_TOKEN_FILE=$(pwd)/web-identity-token

- echo $BITBUCKET_STEP_OIDC_TOKEN > $(pwd)/web-identity-token

- aws sts assume-role-with-web-identity --role-arn ${AWS_ROLE_ARN} --role-session-name admin --web-identity-token "$BITBUCKET_STEP_OIDC_TOKEN" --duration-seconds 1000

- status=$(aws elbv2 describe-target-health --target-group-arn ${TARGET_GROUP_ARN} --targets Id=${target_instance_id} --query 'TargetHealthDescriptions[0].TargetHealth.State' --output text)


pipelines
:

  custom:

    deploy-mainnet:

      - target_instance=API01

      - target_instance_id=${BITBUCKET_VARIABLE_API01}

      - <<: *mainnet-detach

      - <<: *mainnet-attach

      - target_instance=API02

      - target_instance_id=${BITBUCKET_VARIABLE_API02}

      - <<: *mainnet-detach

      - <<: *mainnet-attach

 

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 2, 2023

Hello @김주희 and thank you for reaching out to Community!

Currently, Bitbucket Pipelines does not support using variables to specify the runner's labels in the step definition. We do have an existing feature request for it at :

We suggest you Vote for that feature so that our product managers better understand the interest, and you can also add yourself as a Watcher to get notified whenever there's any update on that feature.

In the meantime, you will need to define two different steps where in each step you explicitly provide the runner label in the runs-on parameter, without using variables.

Thank you, @김주희 !

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events