How to configure a "Multibranch Pipeline" with configuration-as-code

Hi! I can successfully configure manually (via the UI) a Multibranch Pipeline item and have some tests run on my project that is in a git repo.

I am trying to figure out how to configure the Multibranch Pipeline item with the configuration as code plugin. I have successfully used the configuration as code plugin to configure users, credentials, SSH keys to access the remote git repo, etc but

  1. from “Dashboard → Manage Jenkins → Configuration as Code → View Configuration” I don’t see any entries related to the Multibranch Pipeline item
  2. I looked in the configuration-as-code demos but couldn’t find a related example

I am new to Jenkins so I might be looking at the wrong thing. I also hope this is the right place to ask a question about the configuration-as-code plugin

1 Like

Hi @vkatsikaros :wave:

As far as I know, you can’t configure jobs with JCasc.
When I need to add jobs, I just create one within the Jenkins UI, then copy it from the filesystem to another Jenkins instance if needed.

My $0.02.

Hi @poddingue

First of all thanks, because I am new to jenkins and didn’t know that these “items” (as in “Dashboard → New Item”) are called “jobs” :slight_smile:

I saw your approach and will follow it. I might be completely wrong, but from reading the docs I understand that it’s the Job DSL plugin that is responsible of generating the xml files in /var/lib/jenkins/jobs/JOB_NAME/ or can jenkins generate them on its own, without any help from a plugin?

1 Like

@poddingue I’d like to ask what is the purpose of the jobs/JOB_NAME/indexing/indexing.xml

I notice that you store it in your git repo and then copy/restore to another jenkins (like I do - I restore it if I rebuild my jenkins VM image

However, I noticed that the contents of the file change during builds. So I am wondering if there is anything important stored in that file that could cause any jenkins data to go out of sync or in a bad state?

This is a diff of 2 different snapshots of indexing/indexing.xml from different times (after jenkins performed some builds)

<     <long>7462</long>
>     <long>6829</long>
<   <timestamp>1689151569748</timestamp>
<   <duration>7462</duration>
>   <timestamp>1689151449648</timestamp>
>   <duration>6829</duration>

This approach is a few months old and may not be the best example to follow. I apologize for any confusion caused. Currently, I simply copy the config.xml file, and it appears to be sufficient for the jobs to function in a new Jenkins instance.