Venkatesh
Venkatesh

Reputation: 31

Triggering a new jenkins build through ansible

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.

Upvotes: 3

Views: 6451

Answers (1)

VonC
VonC

Reputation: 1324657

Alternatively, you could use the uri_module:

- name: Queue build of a project in Jenkins
  uri:
    url: "http://{{ jenkins.host }}/job/{{ jenkins.job }}/build?token={{ jenkins.token }}"
    method: POST
    user: "{{ jenkins.user }}"
    password: "{{ jenkins.password }}"
    force_basic_auth: yes
    status_code: 201

That does use the Jenkins Remote access API

Upvotes: 4

Related Questions