Skip to content
\n

And here’s my .gitlab-ci.yml configuration:

\n
pre-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
\n

Expected Behavior

\n

The pipeline should be triggered successfully, and the pre-commit job defined in the .gitlab-ci.yml file should run.

\n

Actual Behavior

\n

The pipeline fails to trigger, and I receive the following error:

\n
Traceback (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
\n

Specifications

\n","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"

This doesn't sound like a python-gitlab issue to me.

\n

Please look at: https://docs.gitlab.com/ee/api/merge_requests.html#create-merge-request-pipeline

\n

From the first part of the docs there it says:

\n
\n

Create 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
\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.

\n

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"}}}
Discussion options

You must be logged in to vote

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:

Create 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].

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 ?

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@JohnVillalovos
Comment options

@hailatGH
Comment options

@JohnVillalovos
Comment options

Answer selected by JohnVillalovos
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #3075 on January 02, 2025 17:27.