Reputation: 41
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.
Upvotes: 3
Views: 7821
Reputation: 31
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
Upvotes: 3