8

It is possible to declare variables inside the pipeline file, as in this GitHub example:

# ... env: NODE_VERSION: 16.3.1 FOLDER_PATH: Project # ... steps: - name: Move to project folder run: cd $FOLDER_PATH # ... 

Is it possible to do something similar in the bitbucket pipeline files? (How?)

Thanks any help : )

2
  • You can define them in the Project/Repo settings, why would you want to define them here? Commented Oct 28, 2022 at 6:03
  • 1
    Because I don't want to have to set the same variables every time I create a new project, so I was left with a "template" pipeline file :) And because I think it becomes more explicit :) Commented Oct 28, 2022 at 10:03

2 Answers 2

13

No.

There is a feature request for that https://jira.atlassian.com/browse/BCLOUD-17453 .

Still "gathering interest" though.

The nearest approximation is to write a YAML anchor that exports those vars and use it in every step.

definitions: yaml-anchors: - &setenv-script >- export NODE_VERSION=16.3.1 && export FOLDER_PATH=Project pipelines: default: - step: script: - *setenv-script - ... - step: script: - *setenv-script - ... 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, :) It makes no sense for bitbucket not to have this functionality :)
0

I know this question is a little old. But, I ran across it while looking for a solution myself. I did find that Bitbucket has a feature, that fit my needs, and matches this question (I think) in this post, Adding human interaction back into automated builds

For my use case, I wanted an ability to run shell commands through a custom pipeline to do minor troubleshooting. For example, an "ifconfig" or a "nslookup". Rather simple troubleshooting steps, but within the scope of my container. An example of how I am using this in my code is like this:

pipelines: default: ... custom: Troubleshooting: - variables: - name: COMMAND - step: name: Custom Troubleshooting Commands image: *image runs-on: *runs-on deployment: dev script: - $COMMAND 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.