-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add a simple way to reuse steps from a Task
so we can easily share, say, a git-clone Task inside a Task without requiring 2 Tasks, 2 Pods and forcing a PVC to be used for background see: tektoncd/pipeline#3476
- Loading branch information
1 parent
1a6411d
commit 30a7305
Showing
5 changed files
with
449 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
pkg/triggerconfig/inrepo/test_data/load_pipelinerun/task-append-steps/expected.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: PipelineRun | ||
metadata: | ||
annotations: | ||
lighthouse.jenkins-x.io/appendStepsURL: https://gist.githubusercontent.com/jstrachan/1937a809fd4223f3588db32cbb3a034f/raw/3bb56dd20cae2795e0ec4788d79e18d9486da9d9/sample-git-clone-task.yaml | ||
creationTimestamp: null | ||
name: cheese | ||
spec: | ||
pipelineSpec: | ||
params: | ||
- description: the unique build number | ||
name: BUILD_ID | ||
type: string | ||
- description: the name of the job which is the trigger context name | ||
name: JOB_NAME | ||
type: string | ||
- description: the specification of the job | ||
name: JOB_SPEC | ||
type: string | ||
- description: '''the kind of job: postsubmit or presubmit''' | ||
name: JOB_TYPE | ||
type: string | ||
- description: the base git reference of the pull request | ||
name: PULL_BASE_REF | ||
type: string | ||
- description: the git sha of the base of the pull request | ||
name: PULL_BASE_SHA | ||
type: string | ||
- description: git pull request number | ||
name: PULL_NUMBER | ||
type: string | ||
- description: git pull request ref in the form 'refs/pull/$PULL_NUMBER/head' | ||
name: PULL_PULL_REF | ||
type: string | ||
- description: git revision to checkout (branch, tag, sha, ref…) | ||
name: PULL_PULL_SHA | ||
type: string | ||
- description: git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head' | ||
name: PULL_REFS | ||
type: string | ||
- description: git repository name | ||
name: REPO_NAME | ||
type: string | ||
- description: git repository owner (user or organisation) | ||
name: REPO_OWNER | ||
type: string | ||
- description: git url to clone | ||
name: REPO_URL | ||
type: string | ||
tasks: | ||
- name: cheese | ||
params: | ||
- name: BUILD_ID | ||
value: $(params.BUILD_ID) | ||
- name: JOB_NAME | ||
value: $(params.JOB_NAME) | ||
- name: JOB_SPEC | ||
value: $(params.JOB_SPEC) | ||
- name: JOB_TYPE | ||
value: $(params.JOB_TYPE) | ||
- name: PULL_BASE_REF | ||
value: $(params.PULL_BASE_REF) | ||
- name: PULL_BASE_SHA | ||
value: $(params.PULL_BASE_SHA) | ||
- name: PULL_NUMBER | ||
value: $(params.PULL_NUMBER) | ||
- name: PULL_PULL_REF | ||
value: $(params.PULL_PULL_REF) | ||
- name: PULL_PULL_SHA | ||
value: $(params.PULL_PULL_SHA) | ||
- name: PULL_REFS | ||
value: $(params.PULL_REFS) | ||
- name: REPO_NAME | ||
value: $(params.REPO_NAME) | ||
- name: REPO_OWNER | ||
value: $(params.REPO_OWNER) | ||
- name: REPO_URL | ||
value: $(params.REPO_URL) | ||
taskSpec: | ||
params: | ||
- description: the unique build number | ||
name: BUILD_ID | ||
type: string | ||
- description: the name of the job which is the trigger context name | ||
name: JOB_NAME | ||
type: string | ||
- description: the specification of the job | ||
name: JOB_SPEC | ||
type: string | ||
- description: '''the kind of job: postsubmit or presubmit''' | ||
name: JOB_TYPE | ||
type: string | ||
- description: the base git reference of the pull request | ||
name: PULL_BASE_REF | ||
type: string | ||
- description: the git sha of the base of the pull request | ||
name: PULL_BASE_SHA | ||
type: string | ||
- description: git pull request number | ||
name: PULL_NUMBER | ||
type: string | ||
- description: git pull request ref in the form 'refs/pull/$PULL_NUMBER/head' | ||
name: PULL_PULL_REF | ||
type: string | ||
- description: git revision to checkout (branch, tag, sha, ref…) | ||
name: PULL_PULL_SHA | ||
type: string | ||
- description: git pull reference strings of base and latest in the form 'master:$PULL_BASE_SHA,$PULL_NUMBER:$PULL_PULL_SHA:refs/pull/$PULL_NUMBER/head' | ||
name: PULL_REFS | ||
type: string | ||
- description: git repository name | ||
name: REPO_NAME | ||
type: string | ||
- description: git repository owner (user or organisation) | ||
name: REPO_OWNER | ||
type: string | ||
- description: git url to clone | ||
name: REPO_URL | ||
type: string | ||
stepTemplate: | ||
env: | ||
- name: BUILD_ID | ||
value: $(params.BUILD_ID) | ||
- name: JOB_NAME | ||
value: $(params.JOB_NAME) | ||
- name: JOB_SPEC | ||
value: $(params.JOB_SPEC) | ||
- name: JOB_TYPE | ||
value: $(params.JOB_TYPE) | ||
- name: PULL_BASE_REF | ||
value: $(params.PULL_BASE_REF) | ||
- name: PULL_BASE_SHA | ||
value: $(params.PULL_BASE_SHA) | ||
- name: PULL_NUMBER | ||
value: $(params.PULL_NUMBER) | ||
- name: PULL_PULL_REF | ||
value: $(params.PULL_PULL_REF) | ||
- name: PULL_PULL_SHA | ||
value: $(params.PULL_PULL_SHA) | ||
- name: PULL_REFS | ||
value: $(params.PULL_REFS) | ||
- name: REPO_NAME | ||
value: $(params.REPO_NAME) | ||
- name: REPO_OWNER | ||
value: $(params.REPO_OWNER) | ||
- name: REPO_URL | ||
value: $(params.REPO_URL) | ||
name: "" | ||
resources: {} | ||
steps: | ||
- image: some/linter:1.2.3 | ||
name: lint | ||
resources: {} | ||
workingDir: /workspace/source | ||
- image: gcr.io/jenkinsxio/builder-jx:2.1.142-761 | ||
name: git-clone | ||
resources: {} | ||
script: | | ||
#!/usr/bin/env bash | ||
export SUBDIR="source" | ||
echo "git cloning url: $REPO_URL version $PULL_PULL_SHA to dir: $SUBDIR" | ||
git config --global --add user.name ${GIT_AUTHOR_NAME:-jenkins-x-bot} | ||
git config --global --add user.email ${GIT_AUTHOR_EMAIL:[email protected]} | ||
git config --global credential.helper store | ||
git clone $REPO_URL $SUBDIR | ||
cd $SUBDIR | ||
git checkout $PULL_PULL_SHA | ||
echo "checked out revision: $PULL_PULL_SHA to dir: $SUBDIR" | ||
workingDir: /workspace | ||
status: {} |
11 changes: 11 additions & 0 deletions
11
pkg/triggerconfig/inrepo/test_data/load_pipelinerun/task-append-steps/source.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: cheese | ||
annotations: | ||
"lighthouse.jenkins-x.io/appendStepsURL": "https://gist.githubusercontent.com/jstrachan/1937a809fd4223f3588db32cbb3a034f/raw/3bb56dd20cae2795e0ec4788d79e18d9486da9d9/sample-git-clone-task.yaml" | ||
spec: | ||
steps: | ||
- image: some/linter:1.2.3 | ||
name: lint | ||
workingDir: /workspace/source |
Oops, something went wrong.