DEV Community

Discussion on: GitLab CI: Creating your own pipeline template library 👷

Collapse
 
anhtm profile image
Minh Trinh

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 hidden
  stage: build
  extends: .compile_commit
  variable:
    POM: pom.xml
Enter fullscreen mode Exit fullscreen mode

In Project A:

include:
  - project: 'mygroup/ci_templates'
    ref: 'master'
    file: '/job_templates/pipeline.gitlab-ci.yml'

compile_commit:
  extends: .compile_commit_config
  variables:
    POM: 'myfolder/pom.xml'  # add your variable inside the new job
Enter fullscreen mode Exit fullscreen mode

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