You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Hi All, I am now to Bitbucket pipeline. I am trying to use the YAML anchors to create build steps for dev and qa environments. I am running into an issue 'Incorrect Type. Expected "build execution unit"'. Looking for any help on how to resolve this.
Branches in Repo: dev(MAIN, DEVELOPMENT, PRODUCTION), test
Hi Deepesh and welcome to the community!
I tried using a yml file similar to yours, but I cannot reproduce this error. I see that the second step in your definitions (with the name 'deploy to CF') is missing an anchor, but this shouldn't be an issue if you are not using it anywhere. If you want to use it, you will need to specify an anchor, as you did for the first step.
# Template to deploy builds
image: google/cloud-sdk:latest
definitions:
caches:
# Cache zip cli
zip: /usr/bin
steps:
- step: &zipfile
name: zip files
caches:
- zip
max-time: 2
script:
- apt-get update && apt-get install -y zip
- zip -r function-source.zip . -x *.git* *.yml *.md
- ls -l
- gcloud config set project my-first-project
- echo $GCLOUD_API_KEYFILE_NPROD > gcloud-api-key.json
- gcloud auth activate-service-account --key-file=gcloud-api-key.json
- gcloud storage cp function-source.zip gs://my-first-bucket/bitbucket-pipeline
- step:
name: deploy to CF
max-time: 10
script:
- gcloud config set project my-first-project
- echo $GCLOUD_API_KEYFILE_NPROD > gcloud-api-key.json
- gcloud auth activate-service-account --key-file=gcloud-api-key.json
- gcloud functions deploy Hello_World --gen2 --region=us-east4 --runtime=python311 --source=gs://my-first-bucket/bitbucket-pipeline/function-source.zip --entry-point=hello_http --run-service-account=myfirstsa@my-first-project.iam.gserviceaccount.com --trigger-http --no-allow-unauthenticated
pipelines:
branches:
dev:
- step: *zipfile
Kind regards,
Theodora
Hello Theodora,
Thanks for your reply. The code above is the whole yml file. I am sorry I did not mention the line giving error. It is at below line in the VS code editor. I checked the indentation(VS code) it is using space and not tabs. I think we can ignore this as this is the editor reported issue and not by the pipeline. I have put the new error below.
- step: &zipfile
Per your suggestion I have used online in editor to format it again and used the BB Validator to confirm the file is valid. After running the pipeline it is giving the error as below though there is a step defined.
-------------------------
There is an error in your bitbucket-pipelines.yml at [pipelines > branches > dev > 0]. Step is empty, null, or missing.
-------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Deepesh,
Thank you for the update.
The new error you see is most likely related to indentation. Unfortunately, the validator doesn't report errors when yaml anchors are used (this is a bug: https://jira.atlassian.com/browse/BCLOUD-18299).
If you edit the file online on Bitbucket website, do you see an orange circle next to a line number that indicates where the issue is?
If you cannot figure it out, could you please post a screenshot of the file from the website? If you copy-paste the content here, the indentation will be lost. With a screenshot, I can see if there are any issues with indentation.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.