Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jenkins_job_facts module #35346

Merged
merged 7 commits into from Jan 30, 2018
Merged

Add jenkins_job_facts module #35346

merged 7 commits into from Jan 30, 2018

Conversation

stpierre
Copy link
Contributor

SUMMARY

Adds a new module, jenkins_job_facts, that can be used to discover existence and some basic information about existing Jenkins jobs.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

jenkins_job_facts

ANSIBLE VERSION
ansible 2.5.0 (jenkins-job-facts 15074622c1) last updated 2018/01/25 06:55:33 (GMT -500)
  config file = None
  configured module search path = [u'/home/stpierre/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/stpierre/devel/ansible/lib/ansible
  executable location = /home/stpierre/devel/ansible/bin/ansible
  python version = 2.7.14 (default, Jan 17 2018, 14:28:32) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community. labels Jan 25, 2018
@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2018

The test ansible-test sanity --test boilerplate [?] failed with the following error:

Command "test/sanity/code-smell/boilerplate.sh" returned exit status 2.
>>> Standard Output
== Missing __metaclass__ = type ==
./lib/ansible/modules/web_infrastructure/jenkins_job_facts.py

== Missing from __future__ import (absolute_import, division, print_function) ==
./lib/ansible/modules/web_infrastructure/jenkins_job_facts.py

The test ansible-test sanity --test validate-modules [?] failed with the following errors:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E101 Interpreter line is not "#!/usr/bin/python"
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E105 GPLv3 license header not found in the first 20 lines of the module
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E319 RETURN.color.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E319 RETURN.fullname.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E319 RETURN.name.returned: required key not provided @ data['returned']. Got None
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E319 RETURN.url.returned: required key not provided @ data['returned']. Got None

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 25, 2018
@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2018

The test ansible-test sanity --test boilerplate [?] failed with the following error:

Command "test/sanity/code-smell/boilerplate.sh" returned exit status 2.
>>> Standard Output
== Missing __metaclass__ = type ==
./lib/ansible/modules/web_infrastructure/jenkins_job_facts.py

== Missing from __future__ import (absolute_import, division, print_function) ==
./lib/ansible/modules/web_infrastructure/jenkins_job_facts.py

click here for bot help

@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2018

The test ansible-test sanity --test import --python 2.6 [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 2.7 [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.5 [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.6 [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test import --python 3.7 [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: SyntaxError: from __future__ imports must occur at the beginning of the file

The test ansible-test sanity --test pylint [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:7:0: misplaced-future __future__ import is not the first non docstring statement

The test ansible-test sanity --test validate-modules [?] failed with the following error:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E321 Exception attempting to import module for argument_spec introspection

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Jan 25, 2018
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Jan 25, 2018
@ansibot
Copy link
Contributor

ansibot commented Jan 25, 2018

@Slezhuk @agmezr @berendt @felixfontein @ghjm @hogarthj @inetfuture @jhoekx @jlaska @jtyr @lekum @matburt @mattupstate @mgruener @n0trax @nerzhul @oboukili @ramondelafuente @robinro @scottanderson42 @sermilrod @tarka @tastychutney @wwitzel3

As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add shipit if you would like to see it merged.

click here for bot help

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 25, 2018
@Akasurde Akasurde removed the needs_triage Needs a first human triage before being processed. label Jan 25, 2018
Copy link
Contributor

@resmo resmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs_revision

jobs:
description: All jobs found matching the specified criteria
returned: success
type: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a string or a list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


# Get facts about jobs matching a shell glob using basic auth
- jenkins_job_facts:
name: some-job-*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this use the glob param?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 26, 2018
@ansibot ansibot added needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. and removed needs_ci This PR requires CI testing to be performed. Please close and re-open this PR to trigger CI. labels Jan 26, 2018
@resmo
Copy link
Contributor

resmo commented Jan 26, 2018

a short tests without valid credetials shows a traceback which should be catched.

* including generated source, if any, saving to: /home/resmo/.ansible_module_generated
* ansiballz module detected; extracted module source to: /home/resmo/debug_dir
***********************************
RAW OUTPUT

Traceback (most recent call last):
  File "/home/resmo/debug_dir/ansible_module_jenkins_job_facts.py", line 190, in <module>
    main()
  File "/home/resmo/debug_dir/ansible_module_jenkins_job_facts.py", line 186, in main
    run_module()
  File "/home/resmo/debug_dir/ansible_module_jenkins_job_facts.py", line 168, in run_module
    all_jobs = jenkins_conn.get_all_jobs()
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 814, in get_all_jobs
    jobs = [(0, "", self.get_info(query=JOBS_QUERY)['jobs'])]
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 551, in get_info
    Request(self._build_url(url))
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 430, in jenkins_open
    self.maybe_add_crumb(req)
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 303, in maybe_add_crumb
    self._build_url(CRUMB_URL)), add_crumb=False)
  File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 461, in jenkins_open
    raise JenkinsException('Error in request: %s' % (e.reason))
jenkins.JenkinsException: Error in request: [Errno 111] Connection refused

@resmo
Copy link
Contributor

resmo commented Jan 26, 2018

works for me otherwise, probably one nice feature would be to query by "color"

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 26, 2018
@ansibot
Copy link
Contributor

ansibot commented Jan 26, 2018

The test ansible-test sanity --test no-underscore-variable [?] failed with the following error:

Command "test/sanity/code-smell/no-underscore-variable.sh" returned exit status 2.
>>> Standard Output
== Underscore used as a variable ==
./lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:        # in its return value; we strip that out because the leading _ (and the

The test ansible-test sanity --test validate-modules [?] failed with the following errors:

lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E103 Did not find a call to main
lib/ansible/modules/web_infrastructure/jenkins_job_facts.py:0:0: E321 Exception attempting to import module for argument_spec introspection, 'module 'module' has no attribute 'main''

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jan 26, 2018
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 26, 2018
@resmo
Copy link
Contributor

resmo commented Jan 29, 2018

tested, works for me.

shipit

@resmo resmo merged commit c24e092 into ansible:devel Jan 30, 2018
Lujeni pushed a commit to Lujeni/ansible that referenced this pull request Feb 1, 2018
* Add jenkins_job_facts module

* Fix docs

* Fix connection error handling

* Add support for filtering by color

* Miscellaneous code cleanup

* Spell out "underscore" in comment

* Update required state in docs
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. new_module This PR includes a new module. new_plugin This PR includes a new plugin. support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants