Variables in drone file

I am trying to push a docker container to different ECR registries based on the branch. Right now I need to specify one build step for each registry with a condition on branch, for example:

      image: plugins/ecr
        branch: develop
      image: plugins/ecr
        branch: master

Is there any way to reduce those steps into one and say something like

repo: ${ACCOUNT_ID}

where ACCOUNT_ID would resolve to the correct account ID based on the branch?
I am thinking something like variable indirection in bash (${!varname}) but couldn’t think of a proper solution without having to embed everything in the drone file.

Hi @gufran, there is no way to do what you are asking at this time.

If there are other steps, I suggest you look at using YAML anchors.

If this is all of your .drone.yml, then a matrix may do what you need.

I used variable to define image name, so it should be fine to define the account id as well.

    - app
    - 123456
    - 789012

So you can easily define repo in plugin plugins/ecr:

  repo: ${develop_account_id}${app_name}

This will work in the near term, but please be advised that #1814 will eventually supersede matrix builds at which point they will be deprecated.

I reviewed, but what’s the relationship with matrix?

Could you keep the feature with matrix that I can use with variables? It has been used widely in our drone pipelines. Otherwise, what’s the new way to do it?