jenkins-x / lighthouse

Apache License 2.0
184 stars 114 forks source link

custom tekton pipeline parameters get overwritten by lighthouse #1449

Open gerrnot opened 2 years ago

gerrnot commented 2 years ago

intro

Hi, we are using lighthouse (standalone, without the rest of jenkins-x) in combination with tekton. So far the integration to our Git Servers (Bitbucket Server + GitHub) is working good enough - thanks for that! (ChatOps not working on Bitbucket Server, but we can live with that - another story).

On the other hand, there seems to be a strange bug when using a custom tekton pipeline (that defines its own parameters)

Notice: steps to reproduce below use lighthouse config, full config given below...

in_repo_config:
  enabled:
    'PEP': true # pep is the project where my repo resides

short steps to reproduce

  1. Lets say you define kind: Pipeline with custom param sshGitRepositoryUrl. (Notice lighthouse seems to add additional parmetes like REPO_URL too - which is fine!)
  2. Now you create a kind: PipelineRun yaml file (that is referenced in triggers.yaml) in the source code and specify a concrete custom value as param, e.g.:
    params:
     - name: sshGitRepositoryUrl
       value: ssh://git@mybitbucketserverhost.com:7999/pep/tkn-demo-go-bb.git
  3. git push in the repo from step 2.

long steps to reproduce

(this is just supplementary material to short steps to reproduce)

additional information is provided with detailed sources/configs:

  1. source code repo of the application that contains the .lighthouse folder\ tkn-demo-go-bb.tar.gz
  2. tekton pipeline definition can be found here Hint: in ../test/local.sh there is a local.sh that can be used with minimal adaptation to set up this experimental pipeline.
  3. lighthouse config\ config.yaml:
    
    # docu link: https://github.com/jenkins-x/lighthouse/blob/main/docs/config/lighthouse/github-com-jenkins-x-lighthouse-pkg-config-lighthouse.md

pod_namespace: lighthouse tkn-demo-go-bb.tar.gz

prowjob_namespace: lighthouse

in_repo_config: enabled: 'PEP': true # must have been uppercase here

tide: queries:

expected result

The resulting PipelineRun should contain the custom parameter only once and with the expected value:

  - name: sshGitRepositoryUrl
    value: ssh://git@mybitbucketserverhost.com:7999/pep/tkn-demo-go-bb.git

Lighthouse should leave custom parameters (and their values) as they are: There should not be an interference (lighthouse parameter values copied into custom parameter values).

gerrnot commented 2 years ago

analysis After debugging, I figured out the problem:

There exists a method (determineGitCloneOrMergeTaskParams) that performs some special magic (among similar magic for similar things):

workaround: I swapped the git-clone task to a custom implementation and named it git-checkout (idempotent checkout(+clone) so to speak), then lighthouse does not touch my parameters.

What could be done better? I do not understand why the method determineGitCloneOrMergeTaskParams reads the url parameter and overwrites the value of it, while it actually pretends to known the url better anyway (existing parameter REPO_URL). So why touch further parameters?. However, as the codebase is quite complex and it is hard to know about all downstream effects, I would rather not touch it for now. But closing also seems weird, as I have the feeling the other people could also fall into this pit. Maybe some jenkins-x developer can give a comment and decide whether it is "okay enough" to leave it as it is and perhaps decide to close....