# Trigger a new jenkins job through ansible

**URL:** <https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260>\
**Category:** Ansible Project\
**Created:** [August 15, 2017, 3:50pm UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260 "2017-08-15T15:50:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seeram\_Venkatesh](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Seeram\_Venkatesh](https://forum.ansible.com/u/Seeram_Venkatesh)\
**Post date:** [August 15, 2017, 3:50pm UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260/1 "2017-08-15T15:50:00Z")

</div>

Hi Techies,

I’m looking for a solution where I want to trigger a Jenkins build through Ansible.  
I went through a module called **jenkins\_job** from which I can connect to the jenkins server but not able to trigger a new build.  
Please help me here and TIA.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 16, 2017, 3:12pm UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260/2 "2017-08-16T15:12:59Z")

</div>

Maybe use the uri module to call jenkins rest api - see [https://wiki.jenkins.io/display/JENKINS/Remote+access+API](https://wiki.jenkins.io/display/JENKINS/Remote+access+API)

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 29, 2017, 9:34am UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260/3 "2017-08-29T09:34:37Z")

</div>

Turns out I needed this too. In the end I wound up with the following role (lightly tested in ansible 2.3.0.0 so far).

$ tree -A jenkins-job/  
jenkins-job/  
├── defaults  
│ └── main.yml  
└── tasks  
└── main.yml

2 directories, 2 files  
$ cat jenkins-job/defaults/main.yml

---

<div class="post-metadata">

**Author:** ![Seeram\_Venkatesh](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@Seeram\_Venkatesh](https://forum.ansible.com/u/Seeram_Venkatesh)\
**Post date:** [August 29, 2017, 1:21pm UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260/4 "2017-08-29T13:21:01Z")

</div>

Thank you very much. It really helps me a lot.

Regards,  
Venkatesh

---

<div class="post-metadata">

**Author:** ![Chichu\_sam](https://avatars.discourse-cdn.com/v4/letter/c/ecc23a/32.png) [@Chichu\_sam](https://forum.ansible.com/u/Chichu_sam)\
**Post date:** [July 14, 2018, 6:18pm UTC](https://forum.ansible.com/t/trigger-a-new-jenkins-job-through-ansible/25260/5 "2018-07-14T18:18:09Z")

</div>

Hi Venkat,

CAn you please share the complete file .

I want to use to do full build and deployemnt

Ansible should call jenkins to do build and deployment

PLease help  
thanks  
sam
