-1

I need a help in Jenkins Job Creation with parameters using Ansible. I have checked many documents but not helping much.

I have checked https://docs.ansible.com/ansible/latest/collections/community/general/jenkins_job_module.html but not getting what needs to be added in templates/test.xml?

- name: Create a jenkins job using basic authentication
  community.general.jenkins_job:
    config: "{{ lookup('file', 'templates/test.xml') }}"
    name: test
    password: admin
    url: http://localhost:8080
    user: admin
Zeitounator
  • 38,476
  • 7
  • 53
  • 66
  • 1
    See those `config.xml` files all over your jenkins job tree on your server ? That's a pretty good place to start. If you don't have access to the tree directly, getting `http:///:@your.jenkins.tld/job/JOBNAME/config.xml` with curl or your favorite browser should get you the corresponding file. – Zeitounator Feb 03 '23 at 10:33

1 Answers1

0

Here is an example of a simple Jenkins job configuration in XML format that you can use as a starting point:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <description>Example Jenkins job with parameters</description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>param1</name>
          <description>Example parameter</description>
          <defaultValue>value1</defaultValue>
        </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
  </properties>
  <scm class="hudson.scm.NullSCM"/>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <builders>
    <hudson.tasks.Shell>
      <command>echo "Hello, world!"</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers/>
  <buildWrappers/>
</project>
Zeitounator
  • 38,476
  • 7
  • 53
  • 66
Mask Well
  • 16
  • 2