Skip to content

Commit

Permalink
Merge pull request #211 from stakater/new-docs
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
AsfaMumtaz authored Feb 2, 2024
2 parents bab773c + 2fba628 commit 0c2482a
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@ Let's walk you through creating a Tekton `PipelineRun` using a `Pipeline-as-Code
params:
- name: repo_url
value: "git@github.com:<YOUR-ORG>/<YOUR-REPO-NAME>/" # Place your repo SSH URL
- name: gitrevision
- name: git_revision
value: {{revision}} # Dynamic variable to fetch branch name of the push event on your repo
- name: repo_path
value: {{repo_name}} # Dynamic varaible to fetch repo name
- name: image_registry_url
value: "<docker-registry-url>" # Place image registry URL without https://
value: {{repo_name}} # Dynamic variable to fetch repo name
- name: image_registry
value: "<docker-registry-url>" # Place image registry URL without https:// succeeded by your application name
- name: helm_registry
value: "<https://helm-registry-url>" # Place helm registry URL with https://
pipelineSpec: # Define what parameters will be used for pipeline
params:
- name: repo_url
- name: gitrevision
- name: git_revision
- name: repo_path
- name: image_registry_url
- name: image_registry
- name: helm_registry
workspaces: # Mention what workspaces will be used by this pipeline to store data and used by data transferring between tasks
- name: source
Expand All @@ -72,7 +72,7 @@ Let's walk you through creating a Tekton `PipelineRun` using a `Pipeline-as-Code
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.gitrevision)
value: $(params.git_revision)
workspaces: # Mention Workspaces configuration
- name: source
volumeClaimTemplate:
Expand All @@ -82,11 +82,14 @@ Let's walk you through creating a Tekton `PipelineRun` using a `Pipeline-as-Code
resources:
requests:
storage: 1Gi
- name: ssh-directory # Using ssh-directory workspace for our task to have better security
- name: ssh-dibrectory # Using ssh-directory workspace for our task to have better security
secret:
secretName: [app-name]-ssh-creds # Created this secret earlier
```
1. Provide values for `image_registry`, and helm_registry parameters. You can find the urls from [here](../../../../managed-addons/nexus/explanation/routes.md).
`image_registry` url should be succeeded by your application name. Example: nexus-docker-stakater-nexus.apps.lab.kubeapp.cloud/**review-api**

1. Now create a pull request on the repository with these changes. This should trigger a pipeline on your cluster.

1. You can go to your tenant's build namespace and see the pipeline running.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

### Create PipelineRun with Create Git Tag Task

You have already created a PipelineRun in the previous tutorial. Let's now add another task `create-git-tag` to it.
You have already created a PipelineRun in the previous tutorial. Let's now add another task ['create-git-tag`](https://github.com/stakater-tekton-catalog/create-git-tag) to it.

1. Open up the PipelineRun file you created in the previous tutorial.
1. Now edit the file, so the YAML becomes like the one given below.
Expand All @@ -33,22 +33,22 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
params:
- name: repo_url
value: "git@github.com:<YOUR-ORG>/<YOUR-REPO-NAME>/" # Place your repo SSH URL
- name: gitrevision
- name: git_revision
value: {{revision}} # Dynamic variable to fetch branch name of the push event on your repo
- name: repo_path
value: {{repo_name}} # Dynamic varaible to fetch repo name
- name: image_registry_url
value: "<docker-registry-url>" # Place image registry URL without https://
value: {{repo_name}} # Dynamic variable to fetch repo name
- name: image_registry
value: "<docker-registry-url>" # Place image registry URL without https:// succeeded by your application name
- name: helm_registry
value: "<https://helm-registry-url>" # Place helm registry URL with https://
- name: pull_request_number
value: {{pull_request_number}}
pipelineSpec: # Define what parameters will be used for pipeline
params:
- name: repo_url
- name: gitrevision
- name: git_revision
- name: repo_path
- name: image_registry_url
- name: image_registry
- name: helm_registry
- name: pull_request_number
workspaces: # Mention what workspaces will be used by this pipeline to store data and used by data transferring between tasks
Expand All @@ -70,7 +70,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.gitrevision)
value: $(params.git_revision)
- name: create-git-tag
runAfter:
- fetch-repository
Expand All @@ -81,7 +81,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- name: PR_NUMBER
value: $(params.pull_request_number)
- name: GIT_REVISION
value: $(params.gitrevision)
value: $(params.git_revision)
workspaces:
- name: source
workspace: source
Expand All @@ -101,7 +101,11 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
secretName: git-ssh-creds # Created this secret earlier
```
1. Provide values for image_registry_url, and helm_registry parameters. You can find the urls from [here](../../../../managed-addons/nexus/explanation/routes.md)
**Notice** that we added another value to the **`pipelinesascode.tekton.dev/task`** annotation. The annotation is used by pipeline as code resolver to fetch tasks defined remotely. To explore stakater's Tekton
catalog, please visit [`stakater-tekton-catalog`](https://github.com/stakater-tekton-catalog).

1. Provide values for `image_registry`, and `helm_registry` parameters. You can find the urls from [here](../../../../managed-addons/nexus/explanation/routes.md)
`image_registry` url should be succeeded by your application name. Example: nexus-docker-stakater-nexus.apps.lab.kubeapp.cloud/**review-api**

!!! note
Remember to add the remote task in the annotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

### Create PipelineRun with Create Environment Task

You have already created a PipelineRun in the previous tutorial. Let's now add another task `create-environment` to it.
You have already created a PipelineRun in the previous tutorial. Let's now add another task [`create-environment`](https://github.com/stakater-tekton-catalog/create-environment) to it.
The create environment task utilizes [Tronador](https://docs.stakater.com/tronador/) to create dynamic environments.

1. Open up the PipelineRun file you created in the previous tutorial.
1. Now edit the file so the YAML becomes like the one given below.
Expand All @@ -27,7 +28,9 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
annotations:
pipelinesascode.tekton.dev/on-event: "[push]" # Trigger the pipelineRun on push events on branch main
pipelinesascode.tekton.dev/on-target-branch: "main"
pipelinesascode.tekton.dev/task: "[git-clone, https://raw.githubusercontent.com/stakater/tekton-catalog/main/stakater-create-git-tag/rendered/stakater-create-git-tag-0.0.7.yaml, https://raw.githubusercontent.com/stakater/tekton-catalog/main/stakater-create-environment/rendered/stakater-create-environment-0.0.16.yaml]"
pipelinesascode.tekton.dev/task: "[git-clone,
https://raw.githubusercontent.com/stakater-tekton-catalog/create-git-tag/0.0.12/task/stakater-create-git-tag/stakater-create-git-tag.yaml,
https://raw.githubusercontent.com/stakater-tekton-catalog/create-environment/0.0.16/task/stakater-create-environment/stakater-create-environment.yaml]"
pipelinesascode.tekton.dev/max-keep-runs: "2" # Only remain 2 latest pipelineRuns on SAAP
spec:
params:
Expand All @@ -39,8 +42,8 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
value: {{source_branch}}
- name: repo_path
value: {{repo_name}} # Dynamic varaible to fetch repo name
- name: image_registry_url
value: "<docker-registry-url>" # Place image registry URL without https://
- name: image_registry
value: "<docker-registry-url>" # Place image registry URL without https:// succeeded by your application name
- name: helm_registry
value: "<https://helm-registry-url>" # Place helm registry URL with https://
- name: pull_request_number
Expand All @@ -50,9 +53,9 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
pipelineSpec: # Define what parameters will be used for pipeline
params:
- name: repo_url
- name: gitrevision
- name: git_revision
- name: repo_path
- name: image_registry_url
- name: image_registry
- name: helm_registry
- name: pull_request_number
- name: organization
Expand All @@ -76,7 +79,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.gitrevision)
value: $(params.git_revision)
- name: create-git-tag
runAfter:
- fetch-repository
Expand All @@ -98,7 +101,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- create-git-tag
taskRef:
kind: Task
name: stakater-create-environment-0.0.16
name: stakater-create-environment
params:
- name: CREATE_ON_CLUSTER
value: "true"
Expand All @@ -113,7 +116,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- name: IMAGE_TAG
value: $(tasks.create-git-tag.results.GIT_TAG)
- name: IMAGE_REPO
value: $(params.image_registry_url)
value: $(params.image_registry)
- name: PULL_REQUEST_COMMITS_API # Replace when not using Git
value: https://api.github.com/repos/$(params.organization)/$(params.repo_path)/pulls/$(params.pull_request_number)/commits
workspaces:
Expand All @@ -138,13 +141,24 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
secretName: git-pat-creds
```
**Notice** that we added another **workspace repo-token** to the pipeline run. This workspace utilizes the git-pat-creds secret that we previously created and mounts it to the create-environment task.
!!! note
Remember to add the remote task in the annotations
![create-env](images/create-env-annotation.png)
1. Create a pull request with your changes. This should trigger the pipeline in the build namespace.
![create-env](images/create-env.png)
![create-env-logs](images/create-env-logs.png)
1. Once the task completes, you should be able to see a new project. The name of this project will contain your pr number, application name, and first commit hash of your pr.
1. Create a pull request with you changes. This should trigger the pipeline in the build namespace.
![env-project](images/env-project.png)
![create-env](images/create-env.png)
1. Open up the project and navigate to pods, you should be able to see your application running.
![create-env-logs](images/create-env-logs.png)
![dynamic-env](images/dynamic-env.png)
Great! Let's add more tasks in our pipelineRun in coming tutorials.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Objectives

- Add `code-linting` task to PipelineRun.
- Add `code-linting-mvn` task to PipelineRun.
- Define parameters, workspaces, and tasks within the PipelineRun for building and deploying your application.

## Key Results
Expand All @@ -14,7 +14,7 @@

### Create PipelineRun with Code Linting Task

You have already created a PipelineRun in the previous tutorial. Let's now add another task `code-linting` to it.
You have already created a PipelineRun in the previous tutorial. Let's now add another task [`code-linting`](https://github.com/stakater-tekton-catalog/code-linting-mvn/tree/0.0.4) to it.

1. Open up the PipelineRun file you created in the previous tutorial.
1. Now edit the file so the YAML becomes like the one given below.
Expand All @@ -27,28 +27,31 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
annotations:
pipelinesascode.tekton.dev/on-event: "[pull_request]" # Trigger the pipelineRun on pullrequest events on branch main
pipelinesascode.tekton.dev/on-target-branch: "main"
pipelinesascode.tekton.dev/task: "[git-clone, https://raw.githubusercontent.com/stakater/tekton-catalog/main/stakater-create-git-tag/rendered/stakater-create-git-tag-0.0.7.yaml, https://raw.githubusercontent.com/stakater/tekton-catalog/main/stakater-create-environment/rendered/stakater-create-environment-0.0.16.yaml,https://raw.githubusercontent.com/stakater/tekton-catalog/main/stakater-code-linting/rendered/stakater-code-linting-0.0.3.yaml]"
pipelinesascode.tekton.dev/task: "[git-clone,
https://raw.githubusercontent.com/stakater-tekton-catalog/create-git-tag/0.0.12/task/stakater-create-git-tag/stakater-create-git-tag.yaml,
https://raw.githubusercontent.com/stakater-tekton-catalog/create-environment/0.0.16/task/stakater-create-environment/stakater-create-environment.yaml,
https://raw.githubusercontent.com/stakater-tekton-catalog/code-linting-mvn/0.0.4/task/stakater-code-linting/stakater-code-linting.yaml]"
pipelinesascode.tekton.dev/max-keep-runs: "2" # Only remain 2 latest pipelineRuns on SAAP
spec:
params:
- name: repo_url
value: "git@github.com:<YOUR-ORG>/<YOUR-REPO-NAME>/" # Place your repo SSH URL
- name: gitrevision
- name: git_revision
value: {{revision}} # Dynamic variable to fetch branch name of the push event on your repo
- name: repo_path
value: {{repo_name}} # Dynamic varaible to fetch repo name
- name: image_registry_url
value: "<docker-registry-url>" # Place image registry URL without https://
- name: image_registry
value: "<docker-registry-url>" # Place image registry URL without https:// succeeded by your application name
- name: helm_registry
value: "<https://helm-registry-url>" # Place helm registry URL with https://
- name: pull_request_number
value: {{pull_request_number}}
pipelineSpec: # Define what parameters will be used for pipeline
params:
- name: repo_url
- name: gitrevision
- name: git_revision
- name: repo_path
- name: image_registry_url
- name: image_registry
- name: helm_registry
- name: pull_request_number
workspaces: # Mention what workspaces will be used by this pipeline to store data and used by data transferring between tasks
Expand All @@ -70,12 +73,12 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.gitrevision)
value: $(params.git_revision)
- name: create-git-tag
runAfter:
- fetch-repository
taskRef:
name: stakater-create-git-tag-0.0.7
name: stakater-create-git-tag
kind: Task
params:
- name: PR_NUMBER
Expand All @@ -92,7 +95,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
- create-git-tag
taskRef:
kind: Task
name: stakater-create-environment-0.0.15
name: stakater-create-environment
params:
- name: CREATE_ON_CLUSTER
value: "true"
Expand All @@ -119,7 +122,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
runAfter:
- stakater-create-environment
taskRef:
name: stakater-code-linting-0.0.3
name: stakater-code-linting
kind: Task
workspaces:
- name: source
Expand All @@ -143,6 +146,7 @@ You have already created a PipelineRun in the previous tutorial. Let's now add a
!!! note
Remember to add the remote task in the annotations
![code-lint-annotation](images/code-lint-annotation.png)
1. Create a pull request with you changes. This should trigger the pipeline in the build namespace.
Expand Down
Loading

0 comments on commit 0c2482a

Please sign in to comment.