3

I am working on a Deployment with Bitbucket and got some trouble using the variables. In Bitbucket I set in

Repository Settings / Deployment / Staging:

SOME_VAR = foobar

The bitbucket-pipelines.yml looks like this:

...
definitions:
  steps:
    - step: &build-some-project
      name: 'Build Project'
      script:
        - echo "\$test='$SOME_VAR';" >> file.php
...

I am not able to pass the value of a variable into the file within the script part via echo, but why? I also put it in double qutes (like echo "\$test='"$SOME_VAR"';"). But the result always is just $test=''; = an empty string. The expected result should be $test='foobar';. Does anybody know how to get this working? The variable is not a secure variable.

// edit The Repository Variables are working as well. But: I need the same variable with different values for each environment. Also the Repository Variables are accessable for users with permissions to push into the repo.

1 Answer 1

3

For the script to understand that the variable to be fetched from the deployment variable mention the deployment type

definitions:
  steps:
    - step: &build-some-project
      name: 'Build Project'
      deployment: Staging
      script:
        - echo "\$test='$SOME_VAR';" >> file.php
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.