Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Error when triggering a pipeline for a merge request: "The resulting pipeline would have been empty"#3076

AnsweredbyJohnVillalovos
hailatGH asked this question inQ&A
Discussion options

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 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:

import gitlabfrom .constants import URL, TOKEN, PROJECT_ID, MR_IDgl = gitlab.Gitlab(url=URL, private_token=TOKEN)response = gl.http_request(    "POST",    f"/projects/{PROJECT_ID}/merge_requests/{MR_ID}/pipelines",    timeout=60,    retry_transient_errors=True,)print(response)

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

pre-commit:  image: python:3.12-bookworm  before_script:    - apt update    - apt install -y --no-install-recommends pipx    - PATH="/root/.local/bin:$PATH"    - pipx install pre-commit  script:    - pre-commit run --all-files

Expected Behavior

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

Actual Behavior

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

Traceback (most recent call last):  File "/Users/neXeacon/Desktop/marge-bot/test.py", line 7, in <module>    response = gl.http_request(        "POST",        f"/projects/{PROJECT_ID}/merge_requests/{MR_ID}/pipelines",        timeout=60,        retry_transient_errors=True,    )  File "/Users/neXeacon/Desktop/marge-bot/venv/lib/python3.13/site-packages/gitlab/client.py", line 773, in http_request    raise gitlab.exceptions.GitlabHttpError(gitlab.exceptions.GitlabHttpError: 400: {'base': ['The resulting pipeline would have been empty. Review the rules configuration for the relevant jobs.']}

Specifications

  • python-gitlab version: 5.3.0
  • Gitlab server version (or gitlab.com): 8.7.1
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 newpipeline 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 athttps://docs.gitlab.com/ee/ci/yaml/ and search formerge_requests. Looks like it is required to have in the.gitlab-ci.yml aonly: 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

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 newpipeline 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 athttps://docs.gitlab.com/ee/ci/yaml/ and search formerge_requests. Looks like it is required to have in the.gitlab-ci.yml aonly: 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 ?

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

@hailatGH Hopefully that information will be helpful.

@hailatGH
Comment options

@JohnVillalovos indeed it helped well, thank you

@JohnVillalovos
Comment options

@JohnVillalovos indeed it helped well, thank you

@hailatGH Glad to hear it.

Answer selected byJohnVillalovos
Comment options

https://docs.gitlab.com/ci/pipelines/downstream_pipelines_troubleshooting/#job-in-child-pipeline-is-not-created-when-the-pipeline-runs

Hasrules in job orworkflow, and child pipeline need to do.

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

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


[8]ページ先頭

©2009-2025 Movatter.jp