Open gerrnot opened 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):
git-clone
task?git-clone
REPO_URL
) and override your custom value that you specified in the PipelineRun
.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....
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...
short steps to reproduce
kind: Pipeline
with custom paramsshGitRepositoryUrl
. (Notice lighthouse seems to add additional parmetes likeREPO_URL
too - which is fine!)kind: PipelineRun
yaml file (that is referenced intriggers.yaml
) in the source code and specify a concrete custom value as param, e.g.:long steps to reproduce
(this is just supplementary material to short steps to reproduce)
additional information is provided with detailed sources/configs:
.lighthouse
folder\ tkn-demo-go-bb.tar.gz../test/local.sh
there is a local.sh that can be used with minimal adaptation to set up this experimental pipeline.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:
approve:
PEP/tkn-demo-go-bb: # whitelisted entire pep space below
- trigger
PEP:
apiVersion: tekton.dev/v1beta1 kind: PipelineRun metadata: annotations: kubectl.kubernetes.io/last-applied-configuration: | {"apiVersion":"tekton.dev/v1beta1","kind":"Pipeline","metadata":{"annotations":{},"labels":{"app.kubernetes.io/version":"0.1.0"},"name":"cd-pipeline","namespace":"lighthouse"},"spec":{"description":"from build to production!","params":[{"default":"","name":"BUILD_ID"},{"default":"","name":"JOB_NAME"},{"default":"","name":"JOB_SPEC"},{"default":"","name":"JOB_TYPE"},{"default":"","name":"PULL_BASE_REF"},{"default":"","name":"PULL_BASE_SHA"},{"default":"","name":"PULL_REFS"},{"default":"","name":"REPO_NAME"},{"default":"","name":"REPO_OWNER"},{"default":"","name":"REPO_URL"},{"default":"","description":"git repo url as used by git clone command","name":"sshGitRepositoryUrl"}],"tasks":[{"name":"git-clone","params":[{"name":"url","value":"$(params.sshGitRepositoryUrl)"},{"name":"revision","value":"$(params.PULL_BASE_REF)"},{"name":"depth","value":"0"}],"taskRef":{"name":"git-clone"},"workspaces":[{"name":"output","workspace":"source-ws"},{"name":"ssh-directory","workspace":"ssh-creds"}]},{"name":"git-checkout","params":[{"name":"revision","value":"$(params.PULL_BASE_REF)"}],"runAfter":["git-clone"],"taskRef":{"name":"git-checkout"},"workspaces":[{"name":"gitrepo","workspace":"source-ws"},{"name":"ssh-directory","workspace":"ssh-creds"}]},{"name":"version-calc","params":[{"name":"branch","value":"$(params.PULL_BASE_REF)"}],"runAfter":["git-checkout"],"taskRef":{"name":"git-version"},"workspaces":[{"name":"source","workspace":"source-ws"}]},{"name":"version-print","params":[{"name":"string","value":"$(tasks.version-calc.results.gitVersion)"}],"runAfter":["version-calc"],"taskRef":{"name":"echo"}},{"name":"add-overlay-workspace-to-source","params":[{"name":"script_source","value":"#!/bin/env bash\nset -ex\ncp -rT /workspace/workspace-a /workspace/workspace-c\nif [ \"$(workspaces.source-ws-overlay.bound)\" == \"true\" ];\nthen\n cp -rT /workspace/workspace-b /workspace/workspace-c\nfi\n"}],"runAfter":["git-checkout"],"taskRef":{"name":"bash"},"workspaces":[{"name":"workspace-a","workspace":"source-ws"},{"name":"workspace-b","workspace":"source-ws-overlay"},{"name":"workspace-c","workspace":"source-ws-overlaid"}]},{"name":"docker-build","params":[{"name":"IMAGE","value":"phx-temp-registry.myartifactoryhost.com/pep/$(params.REPO_NAME):$(tasks.version-calc.results.gitVersion)"},{"name":"EXTRA_ARGS","value":["--build-arg=APP_VERSION=$(tasks.version-calc.results.gitVersion)"]}],"runAfter":["add-overlay-workspace-to-source","version-calc"],"taskRef":{"name":"kaniko"},"workspaces":[{"name":"source","workspace":"source-ws-overlaid"},{"name":"dockerconfig","workspace":"docker-config"}]},{"name":"helm-build","params":[{"name":"script_source","value":"echo \"to be implemented yet\"\n"}],"runAfter":["add-overlay-workspace-to-source","version-calc"],"taskRef":{"kind":"Task","name":"bash"}},{"name":"helm-deploy","params":[{"name":"script_source","value":"echo \"to be implemented yet\"\n"}],"runAfter":["helm-build","docker-build"],"taskRef":{"kind":"Task","name":"bash"}},{"name":"git-tag","params":[{"name":"GIT_SCRIPT","value":"git tag '$(tasks.version-calc.results.gitVersion)'\ngit push origin '$(tasks.version-calc.results.gitVersion)'\n"}],"runAfter":["helm-deploy"],"taskRef":{"name":"git-cli"},"when":[{"input":"$(params.PULL_BASE_REF)","operator":"in","values":["master","main","production"]}],"workspaces":[{"name":"source","workspace":"source-ws"},{"name":"ssh-directory","workspace":"ssh-creds"}]}],"workspaces":[{"description":"Location where source is cloned/checked out to","name":"source-ws"},{"description":"Optional Workspace containing files/folders required for building that are typically not part of the source code. Examples: maven settings.xml, jfrog-cli.conf). The contents of source-ws-overlay will be copied to source-ws-overlaid, if provided.\n","name":"source-ws-overlay","optional":true},{"description":"source-ws-overlaid = source-ws + source-ws-overlay (this is done by task add-overlay-workspace-to-source)\n","name":"source-ws-overlaid"},{"description":"git ssh credentials - see https://hub.tekton.dev/tekton/task/git-clone","name":"ssh-creds"},{"description":"docker config as required by https://hub.tekton.dev/tekton/task/kaniko","name":"docker-config"}]}} lighthouse.jenkins-x.io/cloneURI: http://mybitbucketserverhost.com/scm/pep/tkn-demo-go-bb.git lighthouse.jenkins-x.io/job: release creationTimestamp: "2022-05-19T10:29:08Z" generateName: ep-tkn-demo-go-bb-master-release- generation: 1 labels: app.kubernetes.io/version: 0.1.0 created-by-lighthouse: "true" event-GUID: e39f9a16-9a19-45b3-bc5e-c545961f3657 lighthouse.jenkins-x.io/baseSHA: 31105ca37caa431a19173b32593a91328cb9714f lighthouse.jenkins-x.io/branch: master lighthouse.jenkins-x.io/buildNum: "1652956030682" lighthouse.jenkins-x.io/context: release lighthouse.jenkins-x.io/id: ep-tkn-demo-go-bb-master-release-nhnhg lighthouse.jenkins-x.io/job: release lighthouse.jenkins-x.io/lastCommitSHA: 31105ca37caa431a19173b32593a91328cb9714f lighthouse.jenkins-x.io/refs.org: pep lighthouse.jenkins-x.io/refs.repo: tkn-demo-go-bb lighthouse.jenkins-x.io/type: postsubmit tekton.dev/pipeline: cd-pipeline name: ep-tkn-demo-go-bb-master-release-bk27c namespace: lighthouse ownerReferences:
expected result
The resulting PipelineRun should contain the custom parameter only once and with the expected value:
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).