#How to hard code values in backstage template code to take values in jenkins pipeline script

2 messages · Page 1 of 1 (latest)

frigid vault
#

Hi all

I’m trying to create a Jenkins job from a Backstage template using the jenkins:job:create action.

My file structure looks like this:

backstage-app-root/
templates/microservices/springboot/
├─ template.yaml
└─ skeleton/
└─ jenkins-config/
└─ config.xml.hbs

In my template.yaml, I have a step like:

  • id: prepare-jenkins-config
    name: Prepare Jenkins config
    action: fetch:template
    input:
    url: ./skeleton/jenkins-config/config.xml.hbs
    targetPath: ./jenkins/config.xml
    values:
    repoUrl: ${{ parameters.repoUrl }}

Then I call jenkins:job:create with:

  • id: create-job
    name: Create Jenkins Pipeline
    action: jenkins:job:create
    input:
    configPath: ./jenkins/config.xml
    jobName: ${{ parameters.component_id }}
    folderName: CCoE

Issue: When I run the template, Jenkins job creation fails with this error:

ENOENT: no such file or directory,
open 'C:\Users\ss6647\AppData\Local\Temp\1\167e4a82-cb03-4a12-81a6-f81ce812881f\skeleton\jenkins-config\config.xml.hbs'

It looks like the scaffolder is still trying to read the .hbs file from the temp workspace instead of the rendered config.xml.

Has anyone run into this? Do I need to fetch the whole jenkins-config folder instead of just the .hbs file, or am I pointing configPath incorrectly?

clever jasper
#

Hi i think the issue might be in the way you are using fetch:template action because your are saying to read the files from this url ./skeleton/jenkins-config/config.xml.hbs and then u put this optional input called targetPath with by default look at the root or the path defined in the url so i thing the way you have implemented it will try to look at /skeleton/jenkins-config/config.xml.hbs/jenkins/config.xml so its considering a folder