如何使用ansible创建带参数的Jenkins工单?

mccptt67  于 2023-02-07  发布在  Jenkins
关注(0)|答案(1)|浏览(161)

我需要一个帮助Jenkins工作创造与参数使用Ansible。我已经检查了许多文件,但没有太大帮助。
我已经检查了https://docs.ansible.com/ansible/latest/collections/community/general/jenkins_job_module.html,但没有得到需要添加到模板/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
uoifb46i

uoifb46i1#

以下是XML格式的简单Jenkins作业配置示例,您可以将其用作起点:

<?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>

相关问题