Open btey opened 1 year ago
Woohoo! Of course, I use pipelines and will definitely test this feature. I have several ideas for new version received in feedback from users. Where can I report them?
@foxweb Feel free to create new [Enhancement] issues. We will try to do the best we can.
Thank you for you work! There is good improvements! Please check my new PRs.
Attempts to send a test pipeline request cause 500 errors on the OpenProject side. I will study and look further to find out more details.
D, [2023-11-27T23:56:28.000451 #7975] DEBUG -- : Received gitlab webhook pipeline_hook
E, [2023-11-27T23:56:28.001521 #7975] ERROR -- : Failed to handle pipeline_hook from Gitlab: undefined method `iid?' for nil:NilClass undefined method `iid?' for nil:NilClass
D, [2023-11-27T23:56:28.019114 #7975] DEBUG -- : ActiveRecord::SchemaMigration Pluck (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
E, [2023-11-27T23:56:28.021714 #7975] ERROR -- : user=29 undefined method `iid?' for nil:NilClass: undefined method `iid?' for nil:NilClass
D, [2023-11-27T23:56:28.021813 #7975] DEBUG -- : [NoMethodError] undefined method `iid?' for nil:NilClass: modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/pipeline_hook.rb:56:in `associated_with_mr?'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/pipeline_hook.rb:40:in `process'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:68:in `block in pipeline_hook'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:75:in `with_logging'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:67:in `pipeline_hook'; lib_static/open_project/notifications.rb:57:in `block in subscribe'; lib_static/open_project/notifications.rb:81:in `send'; modules/gitlab_integration/lib/open_project/gitlab_integration/hook_handler.rb:60:in `process'; modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb:55:in `block (2 levels) in <class:Engine>'; modules/webhooks/lib/open_project/webhooks/hook.rb:44:in `handle'; modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb:56:in `handle_hook'
OK, I've got 500 response for real pipeline tasks. I don't see result green symbols on GITLAB tab. Look further to find out more details.
Request data: https://gist.github.com/foxweb/c7c287a3272583f53a07541b281e5c11
Request data: https://gist.github.com/foxweb/c7c287a3272583f53a07541b281e5c11
D, [2023-11-28T01:19:32.194672 #7975] DEBUG -- : Received gitlab webhook pipeline_hook
E, [2023-11-28T01:19:32.195405 #7975] ERROR -- : Failed to handle pipeline_hook from Gitlab: undefined method `iid?' for nil:NilClass undefined method `iid?' for nil:NilClass
D, [2023-11-28T01:19:32.209328 #7975] DEBUG -- : ActiveRecord::SchemaMigration Pluck (1.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
E, [2023-11-28T01:19:32.211345 #7975] ERROR -- : user=29 undefined method `iid?' for nil:NilClass: undefined method `iid?' for nil:NilClass
D, [2023-11-28T01:19:32.211416 #7975] DEBUG -- : [NoMethodError] undefined method `iid?' for nil:NilClass: modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/pipeline_hook.rb:56:in `associated_with_mr?'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handler/pipeline_hook.rb:40:in `process'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:68:in `block in pipeline_hook'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:75:in `with_logging'; modules/gitlab_integration/lib/open_project/gitlab_integration/notification_handlers.rb:67:in `pipeline_hook'; lib_static/open_project/notifications.rb:57:in `block in subscribe'; lib_static/open_project/notifications.rb:81:in `send'; modules/gitlab_integration/lib/open_project/gitlab_integration/hook_handler.rb:60:in `process'; modules/gitlab_integration/lib/open_project/gitlab_integration/engine.rb:55:in `block (2 levels) in <class:Engine>'; modules/webhooks/lib/open_project/webhooks/hook.rb:44:in `handle'; modules/webhooks/app/controllers/webhooks/incoming/hooks_controller.rb:56:in `handle_hook'
The only thing that will work is MR type pipelines. Not all pipelines executed in an MR are of that type. The point is that only pipelines that are of type MR include the merge request id in the payload. Without this Id the pipeline cannot be associated with the MR in OpenProject.
Thanks for the testings!
Ok, I see: in my request payload "merge_request": null
.
This is the reason of NoMethodError here.
I don't know version of our instance of GitLab, I think this is GitLab issue. I'll find out version from admin.
Look further to find out more details.
Fixed by adding to .gitlab-ci.yml
config:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
or
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
@btey I see that you have already found out and checked all this, but I still stepped on all the rake 🤣 Thank you for your work!
P.S. GitLab documentation page about this feature — https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html
It is not easy to perform functional tests of the pipline webhook since it requires having an environment configured with GitLab runners in which to run the tests. If you have had the opportunity to test the plugin by activating the webhook for pipelines, please include your comments in this issue indicating if it worked for you or if you found any bugs.
Above all, keep in mind what was commented in the Readme; not all pipelines will be sent from GitLab and processed by OpenProject, only the Merge Request pipelines (see https://gitlab.com/gitlab-org/gitlab/-/issues/345028).
Thank you.