<p>One possibility would be via the Jenkins REST API. I guess the recipe below would be dependent on the particular Jenkins version, so you may need to tweak it a bit. The version I looked at was 2.176.1</p>

<p>Go the Jenkins page for the folder in which you want the job created/restored.
On the page's footer you'll see a <code>REST API</code> link, go there.</p>

<p>On the <code>REST API</code> page you have all sorts of links, customized for your particular Jenkins server and job folder. You're looking for this section:</p>

<blockquote>
  <p>Create Job</p>
  
  <p>To create a new job, post <code>config.xml</code> to <a href="https://your_jenkins_server/your_job_folder_path/createItem" rel="nofollow noreferrer">this URL</a> with query
  parameter name=JOBNAME. You need to send a <code>Content-Type:
  application/xml</code> header. You will get a <code>200</code> status code if the
  creation is successful, or <code>4xx</code>/<code>5xx</code> code if it fails. <code>config.xml</code>
  is the format Jenkins uses to store the project in the file system, so
  you can see examples of them in the Jenkins home directory, or by
  retrieving the XML configuration of existing jobs from
  <code>/job/JOBNAME/config.xml</code>.</p>
</blockquote>

CC BY-SA 4.0
2019-09-27T14:28:22.983Z
2019-09-27T14:28:22.983Z
Dan Cornilescu
<p>I want to restore a deleted Jenkin's job. I had the JobConfig history plugin installed, but it does't have a restore option for that job. It only shows the xml file. I'm wondering how I can restore a Jenkin's job from that xml file.</p>

<p><a href="https://i.sstatic.net/8Vs0B.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/8Vs0B.png" alt="xml code"></a></p>

CC BY-SA 4.0
2019-09-27T06:09:40.130Z
This job seems pretty empty. However, this seems already be answered at https://stackoverflow.com/questions/8424228/export-import-jobs-in-jenkins
papanito
<jenkins>
How do I convert xml to a Jenkins Job?
user12068519
# How do I convert xml to a Jenkins Job?

(Asked by: username_0 on 2019-09-26)

I want to restore a deleted Jenkin's job. I had the JobConfig history plugin installed, but it does't have a restore option for that job. It only shows the xml file. I'm wondering how I can restore a Jenkin's job from that xml file.

[![xml code](https://i.sstatic.net/8Vs0B.png)](https://i.sstatic.net/8Vs0B.png)

**Tags:** jenkins

> **Comments:**
> **username_1**: This job seems pretty empty. However, this seems already be answered at https://stackoverflow.com/questions/8424228/export-import-jobs-in-jenkins  

---

## 1 answers

### Answer by username_2 on 2019-09-27. Score: 2

One possibility would be via the Jenkins REST API. I guess the recipe below would be dependent on the particular Jenkins version, so you may need to tweak it a bit. The version I looked at was 2.176.1

Go the Jenkins page for the folder in which you want the job created/restored.
On the page's footer you'll see a `REST API` link, go there.

On the `REST API` page you have all sorts of links, customized for your particular Jenkins server and job folder. You're looking for this section:

> Create Job
>
> To create a new job, post `config.xml` to [this URL](https://your_jenkins_server/your_job_folder_path/createItem) with query
> parameter name=JOBNAME. You need to send a `Content-Type:
> application/xml` header. You will get a `200` status code if the
> creation is successful, or `4xx`/`5xx` code if it fails. `config.xml`
> is the format Jenkins uses to store the project in the file system, so
> you can see examples of them in the Jenkins home directory, or by
> retrieving the XML configuration of existing jobs from
> `/job/JOBNAME/config.xml`.


---

