In bamboo Job "requirement" section how to define to execute for particular repository.
Asked by Akhil Srivastava:

**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.


Answers:
author: Eduardo Alvarenga
body: Hello [@Akhil Srivastava](/t5/user/viewprofilepage/user-id/5096253)

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](https://confluence.atlassian.com/bamboo/exporting-existing-plan-configuration-to-bamboo-yaml-specs-1018270696.html)

Regards,

Eduardo Alvarenga  
Atlassian Support APAC

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

comments: author: Akhil Srivastava
body: [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410) thanks for response.  

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

Not global.

```
repositories:
- my_repository:
    scope: global
```


author: Eduardo Alvarenga
body: Hi [@Akhil Srivastava](/t5/user/viewprofilepage/user-id/5096253)

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:

* <https://docs.atlassian.com/bamboo-specs-docs/latest/specs.html?yaml#plan-local-vs-linked-vs-project-repositories>

Thank you,

Eduardo Alvarenga  
Atlassian Support APAC


author: Akhil Srivastava
body: Hi [@Eduardo Alvarenga](/t5/user/viewprofilepage/user-id/4365410)

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 * * ?
```

comments: author: Eduardo Alvarenga
body: Hello [@Akhil Srivastava](/t5/user/viewprofilepage/user-id/5096253)

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](https://confluence.atlassian.com/bamkb/how-to-identify-which-repository-triggered-a-build-1093015126.html), 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](https://confluence.atlassian.com/bamboo/configuring-a-variables-task-687213475.html) 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.](https://confluence.atlassian.com/bamkb/conditional-tasks-in-bamboo-1077907046.html)

Best regards,

Eduardo Alvarenga  
Atlassian Support APAC

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