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

In bamboo Job "requirement" section how to define to execute for particular repository.

Akhil Srivastava February 12, 2023

In bamboo Job requirement how to define to execute for particular repository.

sanity:
key: SANITY
tasks:
- script:
interpreter: SHELL
environment: T=sanity
scripts:
- tests/utils/bamboo.sh
description: sanity
final-tasks: !include final.yaml
requirements:
- repo: ansible-coll-ws1-general  (How to define this bamboo plan job section)

 

This requirement is because this plan is execute by multiple child plans.

2 answers

1 accepted

2 votes
Answer accepted
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2023

Hello @Akhil Srivastava

Welcome to Atlassian Community!

Repositories cannot be classified as requirements on a Job. Repositories are linked to the main Plan configuration (or Plan branch). Here's a YAML Specs example of a repository and a checkout task:

---
version: 2
plan:
  project-key: ABC
  key: MF1
  name: Plan-MF1
stages:
- Default Stage:
    manual: false
    final: false
    jobs:
    - Default Job
Default Job:
  key: JOB1
  tasks:
  - checkout:
      repository: my_repository
      force-clean-build: 'false'
      description: Checkout Default Repository
repositories:
- my_repository:
    scope: global
...

This is a sample code and will not work as is. Please consider it as a pseudo-code. I recommend you create the Plan using the UI and then export it using Bamboo's YAML Specs export 

Regards,

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Akhil Srivastava February 12, 2023

@Eduardo Alvarenga thanks for response.

Can I define the scope of my_repository for particular stage or job ?

Not global.

repositories:
- my_repository:
    scope: global

 

Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2023

Hi @Akhil Srivastava

The "scope" defines whether a Repository is Global (Linked), Project or Plan-based. You can't limit it by Job or Stage.

More information here:

Thank you,

Eduardo Alvarenga
Atlassian Support APAC

Like Steffen Opel _Utoolity_ likes this
0 votes
Akhil Srivastava February 12, 2023

Hi @Eduardo Alvarenga 

 

My sample bamboo spec :

I have defined multiple child repositories,

repositories:

- ansible-coll-ws1-general

- ansible-role-vm-tools

- ansible-role-vm-vsphere

- ansible-role-domain-join


triggers:

- bitbucket-server-trigger

- cron: 0 0 12 * * ?

but I have to execute particular stage Integration Tests when there is changes in repositories = ansible-coll-ws1-general

 

---

version: 2

plan:

project-key: SXW

key: ACGEN

name: ansible-coll-ws1-general


stages:

- Unit and Sanity Tests:

manual: false

final: false

jobs:

- sanity


- Integration Tests:

manual: false

final: false

jobs:

- cloud-d42

- cloud-sw


sanity:

key: SANITY

tasks:

- script:

interpreter: SHELL

environment: T=sanity

scripts:

- tests/utils/bamboo.sh

description: sanity

final-tasks: !include final.yaml

requirements:

- buildcluster: lnxbuild-atl



cloud-d42: &int

key: ITCD42

tasks:

- checkout: &checkout

force-clean-build: "true"

description: Checkout Default Repository

final-tasks: !include final.yaml

requirements:

- buildcluster: ws1cs.us05_sdlab



cloud-sw:

<<: *int

key: ITCSW

tasks:

- checkout: *checkout

- script:

<<: *intscript

environment: T="cloud/sw"

description: cloud/sw



repositories:

- ansible-coll-ws1-general

- ansible-role-vm-tools

- ansible-role-vm-vsphere

- ansible-role-domain-join


triggers:

- bitbucket-server-trigger

- cron: 0 0 12 * * ?
Eduardo Alvarenga
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 12, 2023

Hello @Akhil Srivastava

Bamboo doesn't have the ability to run only a specific Stage based on the triggering repository.

For that, you can run a Script Task as the first task of each Job on a Stage and identify what was the repository that triggered the build, then decide to skip that Stage or run it.

If you want to "skip" a Stage and run the next, all their Jobs have to exit successfully (exit 0), otherwise Bamboo will not run the next Stage as it will consider it as a failed build. All tasks of all Jobs in the same stage will have to succeed, meaning you need to write some kind of wrapper script around each command to either run it or exit 0, or you can add a Variables Task immediately after deciding whether to run that Stage that will tell the other tasks whether to run or not run based on a Conditional Task.

Best regards,

 

Eduardo Alvarenga
Atlassian Support APAC

--please don't forget to Accept the answer if the reply is helpful-- 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events