Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,462,810
Community Members
 
Community Events
176
Community Groups

Bitbucket Pipeline replaces word "bitbucket" within url with variable

Edited

Hey,

in our pipeline defintions we're trying to use a custom terraform module which is hosted in a private bitbucket cloud repository. 

Our config looks like the following:

"bitbucket-pipelines.yml"

main:

- step: *build

- step:

name: Deploy to Staging

image: hashicorp/terraform:latest

deployment: Staging

script:

- echo "$BITBUCKET_SA" | base64 -d >> /tmp/gcloud.json

- export GOOGLE_APPLICATION_CREDENTIALS=/tmp/gcloud.json

- cd terraform/

- terraform init -backend-config=./backend/file-for-backend..hcl

- terraform apply -auto-approve -var-file='./setup.tfvars' -var-file='./backend/file-for-vars.tfvars'

"terraform - main.tf"

module "cloud_function" {

source = "git::https://bitbucket.org/<company-workspace>/tfm-gcp.git//cloud_function"

for_each = var.functions

project_id = var.project_id

region = var.region

name = each.value.name

entry_point = each.value.entry_point

trigger_event = each.value.trigger_event

trigger_resource = each.value.trigger_resource

environment_variables = each.value.environment_variables

runtime = var.runtime

source_path = "../functions/"

permissions = ["roles/bigquery.dataEditor"]

}
So no magic involed or substitions but while running the pipline we get the following 
+ terraform init -backend-config=./backend/dspl-dev-fs.hcl

Initializing modules...

Downloading git::https://$AZR_IMG_USERNAME.org/dmk-group/tfm-gcp.git for cloud_function...



Error: Failed to download module

$AZR_IMG_USERNAME is the first variable defined in our workspace variables for pipelines but is not used within the repository or project... so it seems like a bug within the pipeline runtime or am I wrong?
It should just download the defined module, specified in main.tf, but theres an substitution with the word "bitbucket" in URL. 

1 answer

0 votes
Patrik S Atlassian Team Jun 23, 2022

Hello @hemp0r ,

Thank you for reaching out to Atlassian Community!

What I think might be happening here is that your workspace variable  $AZR_IMG_USERNAME is configured as a secure variable and the value of this variable is most likely bitbucketSince secure variables are masked from the pipeline build logs, if a value matching a secured variable appears in the logs (in this case bitbucket), Pipelines will replace it with $VARIABLE_NAME. The value your script/terraform will see is the actual value for the variable, but it will not be revealed in the logs.

Even though you are not directly using the variable in this repository, all the workspace variables are made available to the build container, and in the run time if we find any value in the logs matching a secure variable, it will be masked with the variable name.

Hope that helps to clarify your questions! Let me know in case you have any doubt.

Thank you, @hemp0r .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events