Title: Error when triggering a pipeline for a merge request: "The resulting pipeline would have been empty" · python-gitlab/python-gitlab · Discussion #3076 · GitHub
Open Graph Title: Error when triggering a pipeline for a merge request: "The resulting pipeline would have been empty" · python-gitlab/python-gitlab · Discussion #3076
X Title: Error when triggering a pipeline for a merge request: "The resulting pipeline would have been empty" · python-gitlab/python-gitlab · Discussion #3076
Description: Error when triggering a pipeline for a merge request: "The resulting pipeline would have been empty"
Open Graph Description: Description of the problem, including code/CLI snippet I’m trying to trigger a pipeline for a merge request using the python-gitlab package, but I’m encountering a 400 error with the message: "The ...
X Description: Description of the problem, including code/CLI snippet I’m trying to trigger a pipeline for a merge request using the python-gitlab package, but I’m encountering a 400 error with the message: "...
Opengraph URL: https://github.com/python-gitlab/python-gitlab/discussions/3076
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Error when triggering a pipeline for a merge request: \"The resulting pipeline would have been empty\"","text":"Description of the problem, including code/CLI snippet
\nI’m trying to trigger a pipeline for a merge request using the python-gitlab package, but I’m encountering a 400 error with the message: \"The resulting pipeline would have been empty.\" My GitLab CI configuration does not include any rules for the job, so I’m unsure why this error is occurring.
\nHere’s the code I’m using:
\nimport gitlab\nfrom .constants import URL, TOKEN, PROJECT_ID, MR_ID\n\ngl = gitlab.Gitlab(url=URL, private_token=TOKEN)\n\nresponse = gl.http_request(\n \"POST\",\n f\"/projects/{PROJECT_ID}/merge_requests/{MR_ID}/pipelines\",\n timeout=60,\n retry_transient_errors=True,\n)\n\nprint(response)\n
\nAnd here’s my .gitlab-ci.yml configuration:
\npre-commit:\n image: python:3.12-bookworm\n\n before_script:\n - apt update\n - apt install -y --no-install-recommends pipx\n - PATH=\"/root/.local/bin:$PATH\"\n - pipx install pre-commit\n\n script:\n - pre-commit run --all-files\n
\nExpected Behavior
\nThe pipeline should be triggered successfully, and the pre-commit job defined in the .gitlab-ci.yml file should run.
\nActual Behavior
\nThe pipeline fails to trigger, and I receive the following error:
\nTraceback (most recent call last):\n File \"/Users/neXeacon/Desktop/marge-bot/test.py\", line 7, in <module>\n response = gl.http_request(\n \"POST\",\n f\"/projects/{PROJECT_ID}/merge_requests/{MR_ID}/pipelines\",\n timeout=60,\n retry_transient_errors=True,\n )\n File \"/Users/neXeacon/Desktop/marge-bot/venv/lib/python3.13/site-packages/gitlab/client.py\", line 773, in http_request\n raise gitlab.exceptions.GitlabHttpError(\ngitlab.exceptions.GitlabHttpError: 400: {'base': ['The resulting pipeline would have been empty. Review the rules configuration for the relevant jobs.']}\n
\nSpecifications
\n\n- python-gitlab version: 5.3.0
\n- Gitlab server version (or gitlab.com): 8.7.1
\n
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"This doesn't sound like a python-gitlab issue to me.
\nPlease look at: https://docs.gitlab.com/ee/api/merge_requests.html#create-merge-request-pipeline
\nFrom the first part of the docs there it says:
\n\nCreate a new pipeline for a merge request. A pipeline created from this endpoint doesn’t run a regular branch/tag pipeline. To create jobs, configure .gitlab-ci.yml with only: [merge_requests].
\n
\nAlso look at https://docs.gitlab.com/ee/ci/yaml/ and search for merge_requests. Looks like it is required to have in the .gitlab-ci.yml a only: merge_requests in your config.
\nAny reason to not use: https://python-gitlab.readthedocs.io/en/stable/gl_objects/merge_requests.html#merge-request-pipelines ?
","upvoteCount":1,"url":"https://github.com/python-gitlab/python-gitlab/discussions/3076#discussioncomment-11719234"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:37b63ae7-25a6-9b4d-7af5-6586e4c581ff |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | A248:1BF5D2:39C46BF:4B2CA74:697509F9 |
| html-safe-nonce | da161ef54b8d9c7cba630bd9c18ec987e6ea31a5892d7fb80df8ba9344ffc479 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMjQ4OjFCRjVEMjozOUM0NkJGOjRCMkNBNzQ6Njk3NTA5RjkiLCJ2aXNpdG9yX2lkIjoiNjIzNzIwOTU2NDA5MzQxNzk3NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 383a6ba5f27d61b33d7a33b7335ce001c713a16d1e6186b192fe9bfd6c969c92 |
| hovercard-subject-tag | discussion:7771974 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-gitlab/python-gitlab/3076/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/c8a9ff7cebc6da3ea500c5f304793519a5510ed44ec241537246edeeedcf59da/python-gitlab/python-gitlab/discussions/3076 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c8a9ff7cebc6da3ea500c5f304793519a5510ed44ec241537246edeeedcf59da/python-gitlab/python-gitlab/discussions/3076 |
| og:image:alt | Description of the problem, including code/CLI snippet I’m trying to trigger a pipeline for a merge request using the python-gitlab package, but I’m encountering a 400 error with the message: "The ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4a4bf5f4e28041a9d2e5c107d7d20b78b4294ba261cab243b28167c16a623a1f |
| turbo-cache-control | no-preview |
| go-import | github.com/python-gitlab/python-gitlab git https://github.com/python-gitlab/python-gitlab.git |
| octolytics-dimension-user_id | 28886265 |
| octolytics-dimension-user_login | python-gitlab |
| octolytics-dimension-repository_id | 8077625 |
| octolytics-dimension-repository_nwo | python-gitlab/python-gitlab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8077625 |
| octolytics-dimension-repository_network_root_nwo | python-gitlab/python-gitlab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 488b30e96dfd057fbbe44c6665ccbc030b729dde |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width