Stouts / Stouts.jenkins

Ansible role which manage Jenkins CI
MIT License
41 stars 35 forks source link

Missing jenkins_prefix variable in job.sh template #48

Closed darioblanco closed 8 years ago

darioblanco commented 8 years ago

When changing a Jenkins job in an ansible run where the jenkins_prefix is different than the default, the job.sh template will fail, as it still tries to connect to / instead of the new url. Here I paste the error:

RUNNING HANDLER [Stouts.jenkins : jenkins update jobs] ***** failed: [192.168.230.3] => (item={u'src': u'/home/vagrant/.ansible/tmp/ansible-tmp-1455289178.34-170283538283404/source', u'md5sum': u'7c1cd3484a86437b322f1e4c8c375a5e', u'group': u'jenkins', u'uid': 104, u'dest': u'/var/lib/jenkins/jobs/python-nfon-api.xml', u'checksum': u'def52c32ed36b4bfb02b1659c1d2ef4f9c195b08', 'changed': True, u'owner': u'jenkins', '_ansible_no_log': False, 'item': {u'name': u'python-nfon-api', u'template': u'roles/nfon.ci/files/python-nfon-api.xml'}, u'state': u'file', u'gid': 106, u'mode': u'0644', 'invocation': {u'module_args': {u'src': u'/home/vagrant/.ansible/tmp/ansible-tmp-1455289178.34-170283538283404/source', u'directory_mode': None, u'force': True, u'remote_src': None, u'dest': u'/var/lib/jenkins/jobs/python-nfon-api.xml', u'selevel': None, u'seuser': None, u'setype': None, u'group': u'jenkins', u'content': None, u'serole': None, u'original_basename': u'python-nfon-api.xml', u'delimiter': None, u'mode': None, u'regexp': None, u'owner': u'jenkins', u'follow': True, u'validate': None, u'backup': False}}, '_ansible_notify': [u'jenkins check web ready', u'jenkins check cli ready', u'jenkins update jobs'], u'size': 2338}) => {"changed": true, "cmd": ["/var/lib/jenkins/jobs/job.sh", "python-nfon-api"], "delta": "0:00:00.149526", "end": "2016-02-12 14:59:43.204369", "failed": true, "item": {"_ansible_no_log": false, "_ansible_notify": ["jenkins check web ready", "jenkins check cli ready", "jenkins update jobs"], "changed": true, "checksum": "def52c32ed36b4bfb02b1659c1d2ef4f9c195b08", "dest": "/var/lib/jenkins/jobs/python-nfon-api.xml", "gid": 106, "group": "jenkins", "invocation": {"module_args": {"backup": false, "content": null, "delimiter": null, "dest": "/var/lib/jenkins/jobs/python-nfon-api.xml", "directory_mode": null, "follow": true, "force": true, "group": "jenkins", "mode": null, "original_basename": "python-nfon-api.xml", "owner": "jenkins", "regexp": null, "remote_src": null, "selevel": null, "serole": null, "setype": null, "seuser": null, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1455289178.34-170283538283404/source", "validate": null}}, "item": {"name": "python-nfon-api", "template": "roles/nfon.ci/files/python-nfon-api.xml"}, "md5sum": "7c1cd3484a86437b322f1e4c8c375a5e", "mode": "0644", "owner": "jenkins", "size": 2338, "src": "/home/vagrant/.ansible/tmp/ansible-tmp-1455289178.34-170283538283404/source", "state": "file", "uid": 104}, "rc": 255, "start": "2016-02-12 14:59:43.054843", "stderr": "java.io.IOException: There's no Jenkins running at http://0.0.0.0:8080/\n\tat hudson.cli.CLI.getCliTcpPort(CLI.java:288)\n\tat hudson.cli.CLI.(CLI.java:128)\n\tat hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)\n\tat hudson.cli.CLI._main(CLI.java:479)\n\tat hudson.cli.CLI.main(CLI.java:390)\n\tSuppressed: java.io.FileNotFoundException: http://0.0.0.0:8080/cli\n\t\tat sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1835)\n\t\tat sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440)\n\t\tat hudson.cli.FullDuplexHttpStream.(FullDuplexHttpStream.java:78)\n\t\tat hudson.cli.CLI.connectViaHttp(CLI.java:158)\n\t\tat hudson.cli.CLI.(CLI.java:132)\n\t\t... 3 more", "stdout": "", "stdout_lines": [], "warnings": []}

I think this is fixed changing the L4 job.sh.j2 to

export CLI="java -jar {{jenkins_home}}/jenkins-cli.jar {{jenkins_cli_extra_opts}} -s {{ jenkins_url }}{{ jenkins_prefix }}"

mickaeltr commented 8 years ago

Hello, Instead always having to specify the prefix after the url, I thought of including the prefix in the url. What do you think? https://github.com/mickaeltr/Stouts.jenkins/commit/ad2007610967ff03ba373fe3d52f854cae7e29c7

klen commented 8 years ago

@mickaeltr I think you are right here. @sharkerz Thank you for the report.