Search code examples
bitbucketbitbucket-pipelines

bitbucket pipelines variables in line


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 : )


Solution

  • 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
              - ...