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,461,703
Community Members
 
Community Events
176
Community Groups

How to reuse code from "script" on bitbucket-pipelines.yml?

Edited

Hello community, 

I'm trying to configure bitbucket-pipelines.yml to deploy to another remote. The file is Valid according to the https://bitbucket-pipelines.prod.public.atl-paas.net/validator.

However, I'm getting "Configuration error".

bb_pipelines.png

 

Here's the yml:

# Ideally use an image with php, php extensions & composer.
# i.e. image: imagexmedia/ci:latest
# See: https://confluence.atlassian.com/bitbucket/php-with-bitbucket-pipelines-873907835.html
image: lbausch/laravel-ci:php81

# Defines single re-usable scripts.
script_definitions:
scripts:
env-setup: &env-setup
- export BIN_DIR=$BITBUCKET_CLONE_DIR/vendor/bin
composer-tasks: &composer-tasks
- composer self-update --2
- composer install --no-interaction --optimize-autoloader
compile-assets-dev: &compile-assets-dev
- npm install
- npm run dev
compile-assets-prod: &compile-assets-prod
- npm install
- npm run prod
remote-push: &remote-push
- git config --global user.name bitbucket-pipelines
- git config --global user.email commits-noreply@bitbucket.org
- git remote add platformsh q4wbvsyds6mfm@git.ca-1.platform.sh:q4wbvsyds6mfm.git
- git checkout $BITBUCKET_BRANCH
- git add --all
- git commit -m"Bitbucket build - $BITBUCKET_BUILD_NUMBER, Commit $BITBUCKET_COMMIT"
- git push platformsh $BITBUCKET_BRANCH

# Defines re-usable steps.
step_definitions:
- validate: &validate
name: 'Validation Tasks.'
caches:
- composer
script:
- *env-setup
- *composer-tasks
- ${BIN_DIR}/phpcs --standard=./phpcs.xml -p
- deploy-branch: &deploy-branch
name: 'Deploy branch to remote.'
caches:
- composer
script:
- *env-setup
- *composer-tasks
- *compile-assets-dev
- *remote-push
- deploy-prod: &deploy-prod
name: 'Deploy branch to remote (PROD).'
caches:
- composer
script:
- *env-setup
- *composer-tasks
- *compile-assets-prod
- *remote-push

# Bitbucket pipeline definitions.
pipelines:
default:
- step: *validate
pull-requests:
'**':
- step: *validate
branches:
main:
- step: *validate
- step: *deploy-prod
stage:
- step: *validate
- step: *deploy-branch
develop:
- step: *validate
- step: *deploy-branch

 

Can you please help me to create some reusable "steps" under the "script"?

 

Thanks,
Carol

3 answers

It works fine for me. I think the problem is how you're defining the anchors.

Instead of this:

script_definitions:
scripts:
env-setup: &env-setup
- export BIN_DIR=$BITBUCKET_CLONE_DIR/vendor/bin

Try this:

script_definitions:
scripts:
- &env-setup export BIN_DIR=$BITBUCKET_CLONE_DIR/vendor/bin
0 votes
Caroline R Atlassian Team Jan 31, 2022

Hi, @Carol, welcome to the community! 

Currently, script definitions are not supported. We do have a feature request to add the ability to use script entity for YAML anchors as you can see here:

I would suggest that you add your vote there (by selecting the Vote for this issue link) as the number of votes helps the development team and product managers better understand the demand for new features. 

You are more than welcome to leave any feedback, and you can also add yourself as a watcher (by selecting the Start watching this issue link) if you'd like to get notified via email on updates.

Implementation of new features is done as per our policy here and any updates will be posted in the feature request. 

With that said, I believe the following link might help you to change your YAML file:

I hope this helps!

Kind regards,
Caroline 

what is the error message?

This is the error on the Pipelines UI

There is an error in your bitbucket-pipelines.yml at [pipelines > branches > main > 0 > step > script > 0]. To be precise: This section should be a string or a map (it is currently defined as a list).

bb_pipelines.png

 

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events