Bootstrapping PipelineRuns from scripts
Originally tekton-ci was written to convert a GitLab CI script to a Tekton PipelineRun, and under the hood this is still what it’s doing.
But, you can use it manually to bootstrap a PipelineRun definition from a script definition.
image: maven:3-alpine
build:
script:
- mvn -B clean package
To convert this to a PipelineRun:
$ tekton-ci convert --pipeline-file testing.yaml \
--repository-url https://github.com/jenkins-docs/simple-java-maven-app.git \
--branch master > converted.yaml
This will convert the simple definition to a PipelineRun definition, this will include the following Task.
spec:
pipelineSpec:
tasks:
- name: build-stage-default
runAfter:
- git-clone
taskSpec:
steps:
- args:
- -c
- mvn -B clean package
command:
- sh
env:
- name: CI_PROJECT_DIR
value: $(workspaces.source.path)
image: maven:3-alpine
name: ""
resources: {}
workingDir: $(workspaces.source.path)
workspaces:
- name: source
workspaces:
- name: source
workspace: git-checkout
workspaces:
- name: git-checkout
serviceAccountName: default
workspaces:
- name: git-checkout
persistentVolumeClaim:
claimName: shared-task-storage
This will convert more complex tasks, and generate the correct PipelineRun definition to execute a Tekton task, all the functionality of the currently understood syntax is available.
One thing to be aware of, the PipelineRun requires a shared-task-storage
PVC, there’s an example here