Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rules documentation #2932

Merged
merged 40 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5c4daee
New rules page
clbarrell Aug 15, 2024
700dda9
First pass editing Rules docs
matthewborden Aug 21, 2024
33b6495
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
b647b89
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
6d18085
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
0139de3
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
b381f73
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
35fb71a
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
df7cc28
Update pages/pipelines/rules.md
matthewborden Aug 22, 2024
906e418
Add extra detail about rules.
l-suzuki Aug 26, 2024
dd804d9
Refine rules docs
l-suzuki Aug 26, 2024
e1dc435
Add rest api docs
l-suzuki Aug 26, 2024
44cc892
Add rules to the nav, restructure into sections.
l-suzuki Aug 26, 2024
134ef8f
Add descriptions for finding pipeline and rule uuids for api calls
l-suzuki Aug 26, 2024
d2a0775
Add descriptions for rule and pipeline uuids
l-suzuki Aug 26, 2024
e3d531b
Add cookbook for rules
l-suzuki Aug 26, 2024
45db920
Add rule cookbook to graphql nav
l-suzuki Aug 26, 2024
9c700f9
UI -> interface
l-suzuki Aug 26, 2024
bdc8bc7
Run bundle exec rake graphql:generate
l-suzuki Aug 26, 2024
6cfada1
Fix url links and typos, rename triggered/triggering to source/target…
l-suzuki Aug 27, 2024
8dcc18b
Flesh out example use cases
l-suzuki Aug 29, 2024
cd0d595
Fix broken links, renumber steps, and remove formatting from headings.
gilesgas Aug 30, 2024
fb19e46
Add Rules entry for GraphQL Cookbook and fix more linting issues.
gilesgas Aug 30, 2024
66b105d
Remove extra line endings from end of Rules GraphQL page.
gilesgas Aug 30, 2024
5bfacf7
Add missing link to GraphQL Cookbooks Overview page.
gilesgas Aug 30, 2024
2c6282c
Ran rake to rebuild the GraphQL nav.
gilesgas Aug 30, 2024
443c430
Merge remote-tracking branch 'docs-public/main' into pipeline-rules
gilesgas Aug 30, 2024
5158fbe
Add spec test for Rules entry.
gilesgas Sep 1, 2024
159304b
Complete t/w review of rules overview page.
gilesgas Sep 2, 2024
05db421
Restructure rules landing page to remove '/overview' requirement from…
gilesgas Sep 3, 2024
36de2d4
Fix broken links.
gilesgas Sep 3, 2024
d07d378
Fix up Manage rules page. And a few more tweaks to the rules landing …
gilesgas Sep 3, 2024
f341749
Fix pedantic linter.
gilesgas Sep 3, 2024
bcd9193
Final tweaks to rules' feature's API pages. Fix GraphQL query syntax …
gilesgas Sep 4, 2024
0c10f0e
Streamline rules intro a little more.
gilesgas Sep 4, 2024
472eaa5
More intro tweaks and fix another typo in GraphQL query.
gilesgas Sep 4, 2024
0791802
Add 'early access' note to top of Rules overview page.
gilesgas Sep 5, 2024
b821699
Fix terminology around hash > JSON object, and tweak early access not…
gilesgas Sep 5, 2024
0d8bab0
Fix typo.
gilesgas Sep 5, 2024
5a32705
Minor sentence tweak to make it read less clunkily.
gilesgas Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pages/clusters/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ You can create as many clusters as your require for your setup.

Learn more about working with clusters in [Manage clusters](/docs/clusters/manage-clusters).

>📘 Pipeline triggering
> Pipelines associated with one cluster cannot trigger pipelines associated with another cluster
> 📘 Pipeline triggering
> Pipelines associated with one cluster cannot trigger pipelines associated with another cluster, unless a [rule](/docs/pipelines/rules) has been created.
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

### How should I structure my queues

Expand Down
127 changes: 127 additions & 0 deletions pages/pipelines/rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Pipeline rules
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

Pipeline rules is a Buildkite feature used to manage and organize permissions between pipelines and other resources.
matthewborden marked this conversation as resolved.
Show resolved Hide resolved

## Understanding pipeline rules

Rules express that an action is allowed between two known resources, such as a pipeline. A source and a target are provided, and an action is inferred from the rule. Rules allow you to break out of the defaults.

Pipeline rules encapsulate permissions between resources, enabling the following:

- Rules allow one resource (source) to perform an action on another resource (target)
- Rules override default permissions, such as team-based access or build creator permissions
- Each rule defines a one-to-one relationship between resources
- Define rules using a specific format: `target_type.action.source_type`
- Only admins can create and access rules as part of the organization settings

## Pipeline rules best practices

### How should I use rules?

Use rules to manage explicit permissions between pipelines and other resources. Rules are typically used in tandem with [clusters](/docs/clusters/overview) to increase security and control, where clusters set hard boundaries and rules provide exceptions.

The most common patterns for rule configurations are based on your organization's needs:

- Cross-cluster pipeline triggering
- Allowing specific pipelines to access certain secrets (not yet available)
- Granting test suites access to pipeline artifacts (not yet available)

You can create as many rules as you require.

### Example rule use
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

Imagine you use two clusters to separate environments necessary for building your application and deploying your application. Ordinarily no pipelines in those clusters would be able to trigger each other due to the boundaries of clusters. Creating a rule would allow you to maintain separation of environments and still support separate pipelines for building, testing and deploying.

Therefore, an example rule would be:

```json
{
"rule": "pipeline.trigger_build.pipeline",
"value": {
"triggering_pipeline_uuid": "{uuid-of-build-pipeline}",
"triggered_pipeline_uuid": "{uuid-of-deploy-pipeline}"
}
}
```

## Create a rule

Admins can create new rules on the **Rules** page in the **Organization settings**, as well as through the REST API's or GraphQL API's create-a-rule feature.
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

### Using the Buildkite interface
matthewborden marked this conversation as resolved.
Show resolved Hide resolved

To create a new cluster using the Buildkite interface:
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

1. Select **Settings** in the global navigation to access the **Organization settings** page.
2. Select the **Rules** page in the Pipelines section.
matthewborden marked this conversation as resolved.
Show resolved Hide resolved
3. Select **New rule**.
4. Under **Rule name**, select the type of rule you want to create, such as `pipeline.trigger_build.pipeline`.
5. Fill out the UUIDs of the pipelines you wish to create a target for. Access the UUIDs of your pipelines on their **Settings** page under the **GraphQL API integration** section.
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved
6. Select **Submit**.

### Using the REST API
l-suzuki marked this conversation as resolved.
Show resolved Hide resolved

To [create a new rule](/docs/apis/rest-api/clusters#clusters-create-a-cluster) using the [REST API](/docs/apis/rest-api), run the following example `curl` command:

```bash
curl -H "Authorization: Bearer $TOKEN" \
-X POST "https://api.buildkite.com/v2/organizations/{org.slug}/clusters" \
-H "Content-Type: application/json" \
-d '{
"name": "Open Source",
"source": "A place for safely running our open source builds",
"target": "\:technologist\:",
}'
```

where:

<%= render_markdown partial: 'apis/descriptions/rest_access_token' %>

<%= render_markdown partial: 'apis/descriptions/rest_org_slug' %>

- other fields here

### Using the GraphQL API

<!-- PR FOR CREATING GRAPHQL RULES https://github.com/buildkite/buildkite/pull/18259 -->

Rules can be filtered by sourceType, targetType, and action.

Only users with `manage_organization_rules` permissions are allowed to list rules.

Example query

```
query RulesQuery {
organization(slug: "compute-local") {
name
rules(first: 3, targetType: PIPELINE) {
edges {
node {
id
name
targetType
sourceType
source {
... on Pipeline {
uuid
}
}
target {
... on Pipeline {
uuid
}
}
effect
action
createdBy {
id
name
}
}
}
}
}
}
```
Loading