2

I have a Tekton Pipeline and PipelineRun definitions. But, I couldn't achieve to run Pipeline via passing parameter.

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: build-deploy-
  labels:
    tekton.dev/pipeline: build-deploy
spec:
  serviceAccountName: tekton-build-bot
  pipelineRef:
    name: build-deploy
  params:
    - name: registry-address
      value: $(REG_ADDRESS)
    - name: repo-address
      #value: $(REPO_ADDRESS)
      value: $(REPO_ADDRESS)
    - name: repo-name
      value: $(REPO_NAME)
    - name: version
      value: $(VERSION)
  workspaces:
    - name: source
      persistentVolumeClaim:
        claimName: my-pvc

How can I pass while parameters while trying to run that runner with the following command kubectl create -f pipelinerun.yaml?

Example:

value: $(REG_ADDRESS) -> I wanted to pass registry address as right before the running pipeline instead of giving hard-coded constant.

jsotola
  • 2,238
  • 1
  • 10
  • 22
jdev
  • 33
  • 3

2 Answers2

2

You cannot pass those parameters when using kubectl create.

There are two alternatives:

Use tkn cli

You can use tkn, a purpose made CLI for Tekton. Then you can start a run of a Pipeline with, e.g.:

tkn pipeline start build-deploy \
    --param registry-address=yay \
    --param repo-name=nay \
    --workspace name=source,claimName=my-pvc

Initiate pipeline with Trigger

You can setup a Trigger that initiates runs of your Pipeline on certain events, e.g. when you push to Git.

Then your PipelineRun template with parameter mapping is done using a TriggerTemplate

Jonas
  • 121,568
  • 97
  • 310
  • 388
  • thanks Jonas, I was aware of cli commands but I couldn't think to use it. Currenty, I develop my pipeline locally. So, configuring triggerTemplate can be hard. What is the best approach to define pipeline trigger? For now, I should go with manual trigger with the cli. – jdev May 05 '21 at 18:44
  • The trigger is configured against a git repo. For local development. installing the `tkn` cli is the easiest approach. – Jonas May 05 '21 at 19:31
-1

another example would be as bellow:

 tkn pipeline start pipeline-name --showlog \
 -w name=namespace-name,claimName=youor-pvc \
 -w name=git-credentials,secret=gh-token \
 -p repo-url=https://github.com/your-url \
 -p revision=REV-507
3learner
  • 29
  • 5