And 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\nThe pipeline should be triggered successfully, and the pre-commit job defined in the .gitlab-ci.yml file should run.
\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.']}\nThis 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\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
Also 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.
Any 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"}}}-
Description of the problem, including code/CLI snippetI’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. Here’s the code I’m using: And here’s my .gitlab-ci.yml configuration: Expected BehaviorThe pipeline should be triggered successfully, and the pre-commit job defined in the .gitlab-ci.yml file should run. Actual BehaviorThe pipeline fails to trigger, and I receive the following error: Specifications
|
Beta Was this translation helpful? Give feedback.
-
|
This doesn't sound like a python-gitlab issue to me. Please look at: https://docs.gitlab.com/ee/api/merge_requests.html#create-merge-request-pipeline From the first part of the docs there it says:
Also look at https://docs.gitlab.com/ee/ci/yaml/ and search for Any reason to not use: https://python-gitlab.readthedocs.io/en/stable/gl_objects/merge_requests.html#merge-request-pipelines ? |
Beta Was this translation helpful? Give feedback.
-
|
Has |
Beta Was this translation helpful? Give feedback.
This doesn't sound like a python-gitlab issue to me.
Please look at: https://docs.gitlab.com/ee/api/merge_requests.html#create-merge-request-pipeline
From the first part of the docs there it says:
Also 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.ymlaonly: merge_requestsin your config.Any reason to not use: https://python-gitlab.readthedocs.io/en/stable/gl_objects/merge_requests.html#merge-request-pipelines ?