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

[EDGE-1520] Add pipeline templates rest & graphql api documentation #2479

Merged
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
3 changes: 2 additions & 1 deletion app/models/beta_pages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ def self.all
'apis/rest-api/analytics/runs',
'apis/rest-api/analytics/tests',
'agent/clusters',
'apis/rest-api/clusters'
'apis/rest-api/clusters',
'apis/rest-api/pipeline-templates'
]
end
end
36 changes: 35 additions & 1 deletion data/graphql/schema.graphql
jonathanly marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4078,7 +4078,7 @@ type Mutation {
"""
Sets an allowlist of IP addresses for API access to an organization. Please
note that this is a beta feature and is not yet available to all
organizations.
organizations.
"""
organizationApiIpAllowlistUpdate(
"""
Expand Down Expand Up @@ -6630,6 +6630,23 @@ input PipelineCreateInput {
"""
branchConfiguration: String

"""
Choose to keep builds or remove them after a set time period. Pipelines are
scanned once a day for builds that can be removed according to these settings.
Some billing plans require this setting to be enabled.
"""
buildRetentionEnabled: Boolean @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

"""
The minimum number of builds to keep in the pipeline regardless of how old the builds are.
"""
buildRetentionNumber: Int @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

"""
How long is a build kept before it is automatically removed.
"""
buildRetentionPeriod: BuildRetentionPeriods @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

jonathanly marked this conversation as resolved.
Show resolved Hide resolved
"""
If intermediate builds should be canceled as new builds are created
"""
Expand Down Expand Up @@ -7434,6 +7451,23 @@ input PipelineUpdateInput {
"""
branchConfiguration: String

"""
Choose to keep builds or remove them after a set time period. Pipelines are
scanned once a day for builds that can be removed according to these settings.
Some billing plans require this setting to be enabled.
"""
buildRetentionEnabled: Boolean @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

"""
The minimum number of builds to keep in the pipeline regardless of how old the builds are.
"""
buildRetentionNumber: Int @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

"""
How long is a build kept before it is automatically removed.
"""
buildRetentionPeriod: BuildRetentionPeriods @deprecated(reason: "Build retention is now determined by your billing plan. This field is no longer used and always returns null.")

"""
If intermediate builds should be canceled as new builds are created
"""
Expand Down
3 changes: 3 additions & 0 deletions data/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@
path: "apis/rest-api/organizations"
- name: "Pipelines"
path: "apis/rest-api/pipelines"
- name: "Pipeline templates"
path: "apis/rest-api/pipeline-templates"
pill: "beta"
- name: "Builds"
path: "apis/rest-api/builds"
- name: "Jobs"
Expand Down
2 changes: 2 additions & 0 deletions data/nav_graphql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
path: apis/graphql/cookbooks/agents
- name: Clusters
path: apis/graphql/cookbooks/clusters
- name: Pipeline templates
path: apis/graphql/cookbooks/pipeline-templates
- name: Organizations
path: apis/graphql/cookbooks/organizations
- name: Teams
Expand Down
2 changes: 1 addition & 1 deletion pages/apis/agent_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ curl https://agent.buildkite.com

```json
{
"message":"👋"
"message":"👋"
}
```

Expand Down
6 changes: 3 additions & 3 deletions pages/apis/graphql/cookbooks/clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Get the first 10 clusters and their information for an organization:
```graphql
query getClusters {
organization(slug: "organization-slug") {
clusters(first: 10){
edges{
node{
clusters(first: 10) {
edges {
node {
id
uuid
color
Expand Down
145 changes: 145 additions & 0 deletions pages/apis/graphql/cookbooks/pipeline_templates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Pipeline templates

A collection of common tasks with pipeline templates using the GraphQL API.

You can test out the Buildkite GraphQL API using the [Buildkite explorer](https://graphql.buildkite.com/explorer). This includes built-in documentation under the _Docs_ panel.

## List pipeline templates

Get the first 10 pipeline templates and their information for an organization:

```graphql
query GetPipelineTemplates {
organization(slug: "organization-slug") {
pipelineTemplates(first: 10) {
edges {
node {
id
uuid
name
description
configuration
available
}
}
}
}
}
```

## Get a pipeline template

Get information on a pipeline template, specifying the pipeline templates' UUID as the `uuid` argument of the `pipelineTemplate` query:

```graphql
query GetPipelineTemplate {
pipelineTemplate(uuid: "pipeline-template-uuid") {
id
uuid
name
description
configuration
available
}
}
```

## Create a pipeline template

Create a pipeline template for an organization using the `pipelineTemplateCreate` mutation:

```graphql
mutation CreatePipelineTemplate {
pipelineTemplateCreate(input: {
organizationId: "organization-id",
name: "template name",
description: "it does a thing",
configuration: "steps:\n - command: deploy.sh",
available: false
}) {
pipelineTemplate {
id
uuid
name
description
configuration
available
}
}
}
```

## Updating a pipeline template
jonathanly marked this conversation as resolved.
Show resolved Hide resolved

Update a pipeline template on an organization using the `pipelineTemplateUpdate` mutation, specifying the ID for organization and pipeline template:

```graphql
mutation UpdatePipelineTemplate {
pipelineTemplateUpdate(input: {
organizationId: "organization-id",
id: "pipeline-template-id",
configuration: "steps:\n - comand: updated_steps.sh"
available: true
}) {
pipelineTemplate {
id
uuid
name
description
configuration
available
}
}
}
```

## Deleting a pipeline template
jonathanly marked this conversation as resolved.
Show resolved Hide resolved

Delete a pipeline template using the `pipelineTemplateDelete` mutation, specifying the ID for organization and pipeline template:

```graphql
mutation DeletePipelineTemplate {
pipelineTemplateDelete(input: {
organizationId: "organization-id",
id: "pipeline-template-id"
}) {
deletedPipelineTemplateId
}
}
```

## Managing pipeline template assignment on a pipeline
jonathanly marked this conversation as resolved.
Show resolved Hide resolved

Admins and users with manage pipeline permissions can assign a pipeline template to a pipeline using the `pipelineUpdate` mutation:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "manage pipeline" the name of the permission in the UI? If so, I think it would be good to use italics:

Suggested change
Admins and users with manage pipeline permissions can assign a pipeline template to a pipeline using the `pipelineUpdate` mutation:
Admins and users with _manage pipeline permissions_ can assign a pipeline template to a pipeline using the `pipelineUpdate` mutation:

Or, consider the following alternate, which I think reads a little better:

Suggested change
Admins and users with manage pipeline permissions can assign a pipeline template to a pipeline using the `pipelineUpdate` mutation:
Admins and users with permission to manage pipelines can assign a pipeline template to a pipeline using the `pipelineUpdate` mutation:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Manage pipeline" isn't the permission we use in the UI, I used it to collectively describe read_project and create_project permissions :).

Do you think we should be more specific with the permissions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay. Hmmm is there anywhere else that tells them that specific info? The first place I checked was our GraphQL schema docs, but that doesn't include permission requirements. The next place I looked was the Pipeline templates page, which has:

anyone with permission to create or change a pipeline can assign a template.

Is that the equivalent info?

If so, I think it's fine to just use my second suggestion: "Admins and users with permission to manage pipelines can..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The closest page I can think of that has a similar granularity on permissions would be on the pipeline templates rest api page. Each of the endpoints list out what permissions and api token scopes are required in order to use the api.

Cool, I ran with your second suggestion in lieu of any other updates we may want to make in the future :)


```graphql
mutation AssignPipelineTemplate {
pipelineUpdate(input: {
id: 'pipeline-id'
pipelineTemplateId: 'pipeline-template-id'
}) {
pipeline {
id
name
pipelineTemplateId
}
}
}
```

Conversely, pipeline templates can be removed from a pipeline by specifying `pipelineTemplateId` as `null` in the mutation input:

```graphql
mutation UnassignPipelineTemplate {
pipelineUpdate(input: {
id: 'pipeline-id'
pipelineTemplateId: null
}) {
pipeline {
id
name
pipelineTemplateId
}
}
}
```
jonathanly marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions pages/apis/graphql/graphql_cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ There are recipes for a range of different topics, including:
- [Jobs](/docs/apis/graphql/cookbooks/jobs)
- [Agents](/docs/apis/graphql/cookbooks/agents)
- [Clusters](/docs/apis/graphql/cookbooks/clusters)
- [Pipeline templates](/docs/apis/graphql/cookbooks/pipeline-templates)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's match the order used in the navigation:

- [Agents](/docs/apis/graphql/cookbooks/agents)
- [Builds](/docs/apis/graphql/cookbooks/builds)
- [Clusters](/docs/apis/graphql/cookbooks/clusters)
- [Jobs](/docs/apis/graphql/cookbooks/jobs)
- [Pipelines](/docs/apis/graphql/cookbooks/pipelines)
- [Pipeline templates](/docs/apis/graphql/cookbooks/pipeline-templates)
- [Organizations](/docs/apis/graphql/cookbooks/organizations)
- [Teams](/docs/apis/graphql/cookbooks/teams)

(I think I saw the start of a conversation somewhere about the ordering of these pages, but I can't find it now. There were reasons they weren't in alphabetic order, but I think it's fine to switch to that given how many pages we have now)

Copy link
Contributor Author

@jonathanly jonathanly Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great pick up @mbelton-buildkite, I lost track of which pages are automatically generated vs which ones aren't 😅.
That convo I had with Chris mentioned whether or not we should alphabetically sort links under the Pipelines REST API:
image

Do you have opinions on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh okay. Yeah, for reference docs with that many entries, I think moving to order alphabetically is a good idea 😊

I think I have a feature request somewhere to generate index sections like that on Overview pages, so one day it hopefully won't be manual!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks your for input @mbelton-buildkite, I'll go ahead and order the list alphabetically :D

- [Organizations](/docs/apis/graphql/cookbooks/organizations)
- [Teams](/docs/apis/graphql/cookbooks/teams)
4 changes: 2 additions & 2 deletions pages/apis/graphql/schemas/enum/pipelinetemplateorder.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading