0

I have a python script that creates a jenkins job, as below

def create_jenkins_job(self):
    jenk = jenkins.Jenkins(jenkins_url, username=jenkins_user, password=jenkins_token)

    jobs = jenk.create_job('test2', jenkins.EMPTY_CONFIG_XML)
    return True

This successfully creates an empty job as expected. I'm trying to have this job run an Ansible playbook, held locally in the same directory. The ansible plugin is already installed on the jenkins instance. Is it possible to create a job with the ansible parameter and pass the playbook to it?

CEamonn
  • 853
  • 14
  • 37

1 Answers1

0

as per my understanding you want to do two things:

  1. create a job which is having ansible plugin build step.
  2. run the job passing(uploading) a local playbook and run the job using ansible plugin

if it is the case, then here is my answer: 1:

I know creating a sample job and copying it is not a good solution but it would work. But jobs = jenk.create_job('test2', jenkins.EMPTY_CONFIG_XML) is going to create an empty job which wont be having any pre-configuration. So we need some configuration(any existing job's config.xml) to pre-configure the job using python-jenkins api.

ameydev
  • 126
  • 1
  • 1
  • 6