How to concat two variables in bitbucket pipeline yml file

Viewed 382

I wanted to create a new variable in bitbucket pipeline whose value is going to concatenation of two bitbucket tokens, so I tried this but the new value is not working.

image: node:16.13.0
SOME_VALUE: $(date +%Y-%m-%d)-${BITBUCKET_BUILD_NUMBER}

  branches:
    develop:
      - step:
          name: Build
          size: 2x
          script:
            - echo ${SOME_VALUE}

Appreciate any help on this!

1 Answers

This may not work because your variable is not in a step. In Bitbucket Pipelines, each step has its own build environment. You are trying to create a dynamic variable using date, so identify it in a step. If you want to use this variable in multiple steps, you can use artifacts.

image: node:16.13.0

pipelines:
  branches:
    develop:
      - step:
          name: Build
          size: 2x
          script:
            - SOME_VALUE=$(date +%Y-%m-%d)-${BITBUCKET_BUILD_NUMBER}
            - echo ${SOME_VALUE}
Related