I created a profile just to comment and ask some questions. First of all, thank you for such a well written guide. There are very few articles on GitLab CI on the internet. Most are utterly theoretical and very few provides actual workable examples.
Coming to my question, I followed this guide to create a template repository. I have some job templates in the repo, and a pipeline config template which includes these locally available job templates. I am using the pipeline config as a template in other projects. One of the job templates is a maven build job, which looks like this:
Hi Avi, thanks for stopping by! It's amazing to see people like you finding the guide useful and actually following it.
I think the problem is that in your project A, you're declaring the variable POM: 'myfolder/pom.xml' on the pipeline level, and not on the job level. Hence it's perceived as a different variable from the original .compile_commit::variables::POM and GitLab does not parse it into the job
The easiest way to solve this is to make the template config job to be hidden, and then extend it again in Project A and change the variable POM:
In template config:
include:'/job_templates/compile_commit.gitlab-ci.yml'.compile_commit_config:# make this job hiddenstage:buildextends:.compile_commitvariable:POM:pom.xml
In Project A:
include:-project:'mygroup/ci_templates'ref:'master'file:'/job_templates/pipeline.gitlab-ci.yml'compile_commit:extends:.compile_commit_configvariables:POM:'myfolder/pom.xml'# add your variable inside the new job
Another approach would be to set the POM variable to be at the pipeline level from the beginning (remove it from the job and add it in the pipeline level). Then, override it in your Project A like you did. However, I haven't tested this solution so I can't 100% tell you that it will work. But it's worth trying it out. Let me know if that works also!
Minh
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I created a profile just to comment and ask some questions. First of all, thank you for such a well written guide. There are very few articles on GitLab CI on the internet. Most are utterly theoretical and very few provides actual workable examples.
Coming to my question, I followed this guide to create a template repository. I have some job templates in the repo, and a pipeline config template which includes these locally available job templates. I am using the pipeline config as a template in other projects. One of the job templates is a maven build job, which looks like this:
In the pipeline config template, I have extended this job template as
Finally, in the actual project (project A), I have included the pipeline config template as
However, when I run the pipeline in project A, the build process fails to find the pom.xml path and the build fails. What am I doing wrong?
Hi Avi, thanks for stopping by! It's amazing to see people like you finding the guide useful and actually following it.
I think the problem is that in your project A, you're declaring the variable
POM: 'myfolder/pom.xml'
on the pipeline level, and not on the job level. Hence it's perceived as a different variable from the original.compile_commit::variables::POM
and GitLab does not parse it into the jobThe easiest way to solve this is to make the template config job to be hidden, and then extend it again in Project A and change the variable POM:
In template config:
In Project A:
Another approach would be to set the POM variable to be at the pipeline level from the beginning (remove it from the job and add it in the pipeline level). Then, override it in your Project A like you did. However, I haven't tested this solution so I can't 100% tell you that it will work. But it's worth trying it out. Let me know if that works also!
Minh