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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Execute step for all branches AND specified branch Edited

Is it possible to make a pipeline short and clear like this?

pipelines:  
default:    
parallel:
      - step:
          nameSecurity Scan          
script:    
echo "security test all branches"
       - step: 
          
nameLint the node package
          script: 
           - 
echo "lint test all branches"
  branches:
    '{develop,master,staging}':
      - step:
          nameBuild image
          triggerautomatic
          script:
              - echo "building image"
    staging:
      - step:
          nameDeploy to staging
          triggerautomatic
          script:              
echo 'branch is deployed automatically'
    '{develop,master}':
       - step:
          nameDeploy to current branch env
          triggermanual
          script:
              - echo 'branch is deployed manually'

Instead of duplicating build and all other default steps inside all branches steps?
If i run the code above the jobs which are in the Default will be not triggered for specific branches. Specifying all these steps with anchors or duplicating them somehow is a bit messy. 
Do i have an option to specify jobs for all pipelines AND another job for a specific branch?
Thank you.

1 comment

Hi Pavel and welcome to the community.

Do i have an option to specify jobs for all pipelines AND another job for a specific branch?

I'm afraid that this is not possible. The default pipeline runs for all branches that don't have a branch-specific pipeline. If there is a branch-specific pipeline, the default will not run.

Having multiple branch-specific pipelines in the yml file is also something that won't work. The way to achieve what you want without much duplication in the code would be with yaml anchors.

Assuming that you want to have a default pipeline running for branches other than master, develop and staging, you could do something like the following (you can remove the default section if you don't want pipelines running on branches other than master, develop and staging)

 

definitions:
  steps:
    - step: &security-scan
        name: Security Scan
        script:
          - echo "security test all branches"
    - step: &lint
        name: Lint the node package
        script:
          - echo "lint test all branches"
    - step: &build-image
        name: Build image
        trigger: automatic
        script:
          - echo "building image"
    - step: &deploy-to-staging
        name: Deploy to staging
        trigger: automatic
        script:
          - echo 'branch is deployed automatically'
    - step: &deploy-to-current
        name: Deploy to current branch env
        trigger: manual
        script:
          - echo 'branch is deployed manually'

pipelines:
  default:
    - parallel:
      - step: *security-scan
      - step: *lint
  branches:
    '{develop, master}':
      - parallel:
        - step: *security-scan
        - step: *lint
      - step: *build-image
      - step: *&deploy-to-current
  staging:
    - parallel:
      - step: *security-scan
      - step: *lint
    - step: *build-image
    - step: *deploy-to-staging

 

Kind regards,
Theodora

Thank you. I did in the same way, but faced the problem of adding Deployment flag with variable to the steps. So in the current situation i have two choices 1) Mess in global pipeline variables but readable yml 2) Mess and lot or repeats in yml but split variables for each `deployment`.

bb.png

Hi Pavel,

Thank you for your reply. Are you doing deployments to more than one environment?

I'm not sure if you want manual_deploy and auto_deploy to deploy to the same or a different environment, and whether they have the same script or not. It would be useful to have a bit more context, so we can see how to address this.

Kind regards,
Theodora

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,323 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you