Reputation: 1261
I've been stuck on trying to run a GitLab pipeline from a branch in my repo and its driving me crazy. I have a sample branch called test-branch
, but every time I try to run the pipeline manually GitLab shows an error message saying
Pipeline cannot be run
Failed to build pipeline!
I am the owner of the group hence by inherited permissions, I should be able to run a pipeline on any branch by default. I am able to manually run this same pipeline from the main branch, but for any other branch, it simply won't budge. Here is the .gitlab-ci.yaml
file I am using
stages:
- build_artifacts
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "push"
when: never
- if: $CI_PIPELINE_SOURCE == "web"
Run-Pipeline:
stage: build_artifacts
script:
- |
echo "Somevalue" > file.json # Just an example script
artifacts:
paths:
- file.json
Here are some steps I have takes to try and resolve this
This has to be the worst error message GitLab shows, there is no way for me to debug what is going wrong. What am I missing here?
Upvotes: 2
Views: 2624
Reputation: 1261
I figured out the problem. Apparently, GitLab has a certain naming convention for the variables. I added a user defined variable in the gitlab-ci config called SAMPLE-VARIABLE
. Turns out you cannot use -
in the name of the variable. Renaming it to SAMPLE_VARIABLE
did the trick.
However, it would be good for GitLab to give clear error messages rather than throwing such a generic message at the end user and expecting them to figure it out. I spent almost a whole entire day trying out different things to figure out what was exactly going wrong here
Upvotes: 1
Reputation: 1323263
Check first the pipeline through the Lint CI configuration
That will test the validity of your GitLab CI/CD configuration before committing the changes.
An incorrect syntax could explain the runtime error message.
Upvotes: 0