-
Notifications
You must be signed in to change notification settings - Fork 675
Closed
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 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 gitlab
from .constants import URL, TOKEN, PROJECT_ID, MR_ID
gl = 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
Sabian-A
Metadata
Metadata
Assignees
Labels
No labels