Is it possible to make a pipeline short and clear like this?
pipelines: default: - parallel: - step: name: Security Scan script: - echo "security test all branches" - step: name: Lint the node package script: - echo "lint test all branches" branches: '{develop,master,staging}': - step: name: Build image trigger: automatic script: - echo "building image" staging: - step: name: Deploy to staging trigger: automatic script: - echo 'branch is deployed automatically' '{develop,master}': - step: name: Deploy to current branch env trigger: manual 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.
pipelines: default: - parallel: - step: name: Security Scan script: - echo "security test all branches" - step: name: Lint the node package script: - echo "lint test all branches" branches: '{develop,master,staging}': - step: name: Build image trigger: automatic script: - echo "building image" staging: - step: name: Deploy to staging trigger: automatic script: - echo 'branch is deployed automatically' '{develop,master}': - step: name: Deploy to current branch env trigger: manual script: - echo 'branch is deployed manually'
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
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`.
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.
Thank you for your response.
Yes, you are right, the manual and auto-deploy have only one difference - manual or auto-trigger for deployment. And yes, we are deploying to the different environments and we would like to have several "deployment" scopes with the variables but needs to reuse the yml steps. But as you can see on a screenshot we can not utilize "deployment" flag.
It looks like you're new here. Sign in or register to get started.