I am building a pipeline to deploy my .net projects. in my solution I have several azure functions all under same repo. I want to zip and deploy them. I want to reuse my zip script and therefore I have put it in a step. however to path to which files it needs to zip is different per function (.net code). how can i use variables to set the path as part of my pipeline step?
Bitbucket has dedicated support for repository (and even workspace!) variables.
See: https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
@Aron Gombas _Midori_ thanks for your help I have seen this page but I still don't see how I can define and use the variables in the ymal? I need to overwrite the value of the variable in different steps. but everything I have tried my variable's value is not changed. any idea how can i do this. perhaps an example. I really appreciate this
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sschroders,
If you have a Repository, Workspace, or Deployment variable named MyVar, you can reference it in the bitbucket-pipelines.yml file as $MyVar (except if you use a Widnows self-hosted runner for your Pipelines builds, in which case you will need to reference it as $env:MyVar).
For example, the following pipeline will print the value of the variable named MyVar:
image: atlassian/default-image:4
pipelines:
default:
- step:
name: 'First Step'
script:
- echo $MyVar
If you want to change the value of the variable in a second step, you can do it as follows:
image: atlassian/default-image:4
pipelines:
default:
- step:
name: 'First step'
script:
- echo $MyVar
- step:
name: 'Second step'
script:
- MyVar="some other value"
- echo $MyVar
Please keep in mind that this will change the value of the variable only in this second step. If you have a third step, it will read the value of the variable from Repository, Workspace, or Deployment variables, so it will have the original value.
If the different steps that use this variable are deployment steps (with the use of the deployment keyword), you can then create a variable named MyVar in every deployment environment that uses it and give it a different value for each environment (no need to change the value in the yml file).
Please feel free to reach out if you have any questions!
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.