git - creating jenkins jobs with ansible -
i'm working on project deploy jenkins ci server on centos7 using ansible , i'm having problems creating jenkins jobs xml template using ansible.
everything works fine far, want able create jobs, , give them basic configuration xml file using ansible. solution following command jenkins-cli:
sudo java -jar jenkins-cli.jar -s http://localhost:8080 create-job job_test1 < job_test1.xml
this works when entered manually in centos7 box, when put ansible , run it:
- name: create jenkins jobs xml files sudo: yes command: "java -jar {{ jenkins.cli_dest }} -s http://localhost:8080 create-job {{ item.name }} < {{ jenkins_dest }}/{{ item.xml_name }}" with_items: jenkins_jobs
it gives following error message:
stderr: many arguments: < java -jar jenkins-cli.jar create-job name creates new job reading stdin configuration xml file.
does know solution this? far can see i'm doing properly(since command works when not entered ansible)
the command module doesn't support input , output redirection since doesn't pass command string shell. documentation says:
it not processed through shell, variables $home , operations "<", ">", "|", , "&" not work (use shell module if need these features).
so:
- name: create jenkins jobs xml files sudo: yes shell: "java -jar {{ jenkins.cli_dest }} -s http://localhost:8080 create-job {{ item.name }} < {{ jenkins_dest }}/{{ item.xml_name }}" with_items: jenkins_jobs
Comments
Post a Comment