Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CEL Expression doesn't seem to work with Bitbucket server #1677

Open
Mikkelmedetk opened this issue May 3, 2024 · 5 comments
Open

CEL Expression doesn't seem to work with Bitbucket server #1677

Mikkelmedetk opened this issue May 3, 2024 · 5 comments
Assignees

Comments

@Mikkelmedetk
Copy link

Hi,

I've been experimenting a bit with Pipelines as Code together with bitbucket-server.

But it doesn't seem to work with CEL-Expression annotation:
...
annotations:
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch == "master"
...

This is what i observe on the pipeline-as-a-code controller logs
{"level":"info","ts":"2024-05-03T08:13:15.037Z","logger":"pipelinesascode","caller":"bitbucketserver/bitbucketserver.go:174","msg":"Using PipelineRun definition from source pull request SHA: e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"} {"level":"info","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"matcher/annotation_matcher.go:133","msg":"matching pipelineruns to event: URL=https://REDACTED/projects/REDACTED/repos/REDACTED.REDACTED, target-branch=refs/heads/master, source-branch=refs/heads/master, target-event=push","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"} {"level":"error","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"matcher/annotation_matcher.go:172","msg":"there was an error evaluating the CEL expression, skipping: json: cannot unmarshal string into Go value of type map[string]interface {}","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED","stacktrace":"github.com/openshift-pipelines/pipelines-as-code/pkg/matcher.MatchPipelinerunByAnnotation\n\t/go/src/github.com/openshift-pipelines/pipelines-as-code/pkg/matcher/annotation_matcher.go:172\ngithub.com/openshift-pipelines/pipelines-as-code/pkg/pipelineascode.(*PacRun).getPipelineRunsFromRepo\n\t/go/src/github.com/openshift-pipelines/pipelines-as-code/pkg/pipelineascode/match.go:195\ngithub.com/openshift-pipelines/pipelines-as-code/pkg/pipelineascode.(*PacRun).matchRepoPR\n\t/go/src/github.com/openshift-pipelines/pipelines-as-code/pkg/pipelineascode/matc... {"level":"warn","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"matcher/annotation_matcher.go:200","msg":"cannot match pipeline from payload to a pipelinerun in .tekton/ dir","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"} {"level":"warn","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"matcher/annotation_matcher.go:201","msg":"payload target event is with source branch refs/heads/master and target branch master","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"} {"level":"warn","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"matcher/annotation_matcher.go:202","msg":"available configuration of the PipelineRuns annotations in .tekton/ dir","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"} {"level":"warn","ts":"2024-05-03T08:13:15.607Z","logger":"pipelinesascode","caller":"events/emit.go:50","msg":"cannot match pipeline from payload to a pipelinerun in .tekton/ dir, event=, branch=master","provider":"bitbucket-server","event-id":"cc7d5e22-ef40-4575-bd18-d9eb4a10cd70","event-sha":"e516130c8cf654f321c0b0ac7b4011c9ad4b3bd9","event-type":"","namespace":"REDACTED"}

@FM-githubcom
Copy link

Same issue. Did you find a solution?

@enarha
Copy link
Contributor

enarha commented Jun 5, 2024

I'm just starting to look into that issue. I'll follow up with updates here.

@enarha enarha self-assigned this Jun 5, 2024
@Mikkelmedetk
Copy link
Author

Same issue. Did you find a solution?

No but looks like Emil will look into it :)

@enarha
Copy link
Contributor

enarha commented Jul 17, 2024

So I tested that and it worked. There are issues with file and path matching from the CEL expression with BitBucket, but that specific case worked. Here is the annotation I've used: pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch == "main".

Few notes:
First I'm testing with the most recent PAC version if you are willing to give it another try. I see some changes around that code, so there is a chance the issue was fixed.

Second, I'm testing with "Bitbucket Data Center" which is the successor of Bitbucket Server (not supported anymore).

Last thing, that error from the log seems suspicions: "there was an error evaluating the CEL expression, skipping: json: cannot unmarshal string into Go value of type map[string]interface {}". To me it sounds more like an issue with the yaml file. @Mikkelmedetk can you please share you pipelinerun manifest. Obviously feel free to obscure names/data, but please preserve the structure.

@crikke
Copy link

crikke commented Aug 26, 2024

Had the same issue however it works when using event == "pull_request" but not with event == "push"
The version of pac installed is 1.15.1

Edit: Still getting the issues when trying to check if file has changed with the following cel: pipelinesascode.tekton.dev/on-cel-expression: files.all.exists(x, x.matches('tmp/'))

I guess this is something that does not work with bitbucket since it seems like the webhook does not contain files changed unlike the github webhook. See here: https://community.atlassian.com/t5/Bitbucket-questions/WebHook-with-file-changes/qaq-p/770231

If this is the case I would suggest updating the documentation with a note that this is not supported for bitbucket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants