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

**URL:** <https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298>\
**Category:** Using Jenkins\
**Created:** [July 4, 2023, 5:23pm UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298 "2023-07-04T17:23:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vkatsikaros](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vkatsikaros](https://community.jenkins.io/u/vkatsikaros)\
**Post date:** [July 4, 2023, 5:23pm UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298/1 "2023-07-04T17:23:31Z")

</div>

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](https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/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

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [July 5, 2023, 6:21am UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298/2 "2023-07-05T06:21:57Z")

</div>

Hi @vkatsikaros 👋

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](https://github.com/gounthar/MyFirstAndroidAppBuiltByJenkins/tree/stf/jenkins/controller) to another Jenkins instance if needed.

My $0.02.

---

<div class="post-metadata">

**Author:** ![vkatsikaros](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vkatsikaros](https://community.jenkins.io/u/vkatsikaros)\
**Post date:** [July 5, 2023, 8:17am UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298/3 "2023-07-05T08:17:17Z")

</div>

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” 🙂

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](https://plugins.jenkins.io/job-dsl/) 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?

---

<div class="post-metadata">

**Author:** ![vkatsikaros](https://avatars.discourse-cdn.com/v4/letter/v/a87d85/32.png) [@vkatsikaros](https://community.jenkins.io/u/vkatsikaros)\
**Post date:** [July 12, 2023, 8:59am UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298/4 "2023-07-12T08:59:06Z")

</div>

@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)

```auto
20c20
< <long>7462</long>
---
> <long>6829</long>
22,23c22,23
< <timestamp>1689151569748</timestamp>
< <duration>7462</duration>
---
> <timestamp>1689151449648</timestamp>
> <duration>6829</duration>

```

---

<div class="post-metadata">

**Author:** ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)\
**Post date:** [July 17, 2023, 4:28pm UTC](https://community.jenkins.io/t/how-to-configure-a-multibranch-pipeline-with-configuration-as-code/8298/5 "2023-07-17T16:28:05Z")

</div>

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.
