Resolves flake8 BLK related issues.
"BLK100 Black would make changes."
"BLK999 Unexpected exception: ..."
Change-Id: Ic6d4265e3d02b2f2a15ab851eaed98288c62730c
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
The spam caused by jjb not doing anything with a job is not
generally interesting so switch it to a DEBUG level logger.
Change-Id: I0c5277612c8db3a11a1e44d4855b4a51226a8f2c
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
Please review the following patch containing the code changes in
the repo. This patch is a transition patch and is the auto-generated
output of the python-black tool.
Change-Id: I2d2de71da8a105fb62b561899ae78441ddab4032
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
When calling `jenkins-jobs update --delete`, the builder will create an
XML dom tree from the xml string. It fails to correctly encode the
string, which results in a UnicodeEncodeError if the string contains any
non-ascii characters.
Story: 2006374
Task: 36163
Change-Id: I2caf91dcaf2c1b6c03e92a485a3aa51b038b40b1
Signed-off-by: Achim Leitner <git@fjl.de>
Instead of printing the deprecation warning against every generated
config-xml file, print it only once at the beginning of the test
command call to not spam the console.
Change-Id: Ifdcdb1373d44ba6232ea7a5359662cc760353774
Signed-off-by: Thanh Ha <zxiiro@linux.com>
Printed job urls with unicode are now clickable
Avoids unicode decode errors in logging due on
systems, likely python27 systems where
default encoding is ascii.
Change-Id: I17041de05a4388c7b95a9ca04477043424458c67
Creation of nested folders is not possible in
`project-type: folder` in test mode because the
folder name conflicts with the generated XML
filename and an `OSError` is thrown as a result.
This can be resolved by passing the `--config-xml`
flag when running the jobs in test mode. This
commit displays a deprecation message asking the
user to use the `--config-xml` flag.
Change-Id: I6f883040ed3d9b3536ccc2fb305cdddcfde5d765
Story: #2001937
Task: #15050
Makes view logging similar to job one so URLs are printed
inside the logs.
Also assured that URLs for both, views and jobs, are
ending with slash as thats the what Jenkins expected format.
Change-Id: Id34a25b47b4f584f07cc2dc2039cc1a49ab49038
Additional argument for the update subcommand to allow user to update
only jobs currently installed on the Jenkins server and managed by
this tool.
Change-Id: I4b0e997df01057f89896b8caa27dc00b5ca077df
Avoids console span when running in non verbose mode,
especially when using --config-xml which would
create one folder for each job created.
Change-Id: Id5d47c50c5c364068c26437c125e4066b856587c
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
Add print_job_urls = True to [job_builder] to enable output as urls
instead of simple job names when changing them.
Change-Id: I3454606a50ca385c87d8c13d3eab5d30d94cf02f
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
Allows specifying a folder attribute for each job generated, which in
turn is used when creating or uploading to place the job under the
requested folder.
The job name is expanded after defaults are applied, to support the
attribute being defined within a set of defaults applied to a number of
jobs.
This in turn allows for multiple jobs with the same basename to exist,
provided they are targeted at different folders.
Does not support creating the folders if they do not exist.
Change-Id: I8c2157c4c81087cc972a048d1b88d5f08ac65361
This improves UX by using a alphanum sorting which
is more natural to humans: [a1, a2, a10] instead of
[a1, a10, a2].
Change-Id: Ice9c3de282f08e85c8f8a34a27d1b6c0502ca9cb
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
Listing the plugins installed on a Jenkins instance requires full
administrative permissions. For cases where we don't have permission to
read the plugin list, we should just fall back to the default list.
Story: 2000618
Task: 3052
Change-Id: I924f237f5f175216200668d133092f2357f6d9d3
Before, `jenkins-job-builder test -o outdir` would write
outdir/job_name
With the new option `--config-xml`, it writes
outdir/job_name/config.xml
to match the layout that Jenkins uses internally. This is more useful
for diffing against existing Jenkins installations or uploading job
definitions by other means.
Also, it seems better to give the output files an .xml extension.
Change-Id: I78fc7aff531925ee071b8e19f40f766b4af0b5ad
If no value is provided for 'keep' when calling delete_old_managed,
ensure a default empty iterable is used to prevent an exception.
Change-Id: I3110f8e03e287a6ff067b992ed8631e34121a8d2
- Adds the ability for JJB to work with views
- Views can be created, updated, and deleted.
- New modules for List view and Build Pipeline view are added
- New tests for testing the deletion of views
Example View configuration:
- view:
name: MyView
view-type: list
Change-Id: Idb29a4407bcc14593e10a4d951036cb04e8e6c27
Co-Authored-By: Brandon Leonard <brandon.leonard@rackspace.com>
Co-Authored-By: Joao Vale <jpvale@gmail.com>
Co-Authored-By: Lucas Dutra Nunes <ldnunes@ossystems.com.br>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
And rename it to JobCache. The word "Cache" already implies "Storage"
so it makes more sense to name it after the things that it
stores...Jobs!
Change-Id: If7a7a56e8f6a3637f62e285eaa7ba989f67002dc
Since both of these classes essentially build on basic functionality
provided by jenkins.Jenkins, merge them into a single class. Name this
class "JenkinsManager" to avoid confusion with jenkins.Jenkins.
Also moves some tests for update timeout configuration into the
tests.cmd.test_config module from tests.cmd.subcommand.test_update
module, replacing those tests with skipped stubs as reminders to
figure out a better way later.
Change-Id: I13c17bc90e29e702e5e02992e93cf3cdc689731d
The deprecation warning message in this method was confusing and
seemed to be intended for builder.Jenkins.update_job but it's hard to
tell for sure. Seems likely to be an artifact of an outdated patchset
in the parallelize-the-things work done last year because it's not
clear how it could apply to builder.Builder.update_jobs which has a
significantly different use case than parallel_update_job.
Change-Id: Ifb3c1a40d81b0d43ac8e85151f0a99d1502e21db
It came to my attention when I was deciding whether or not to use the
jenkins_jobs.parallel.parallelize decorator to parallelize things in
jenkins_jobs.parser that because it is using the Python threading
library nothing is actually parallelized, only concurrentized (at least
for CPython).
I actually think concurrency is fine for the original use case since
that (ie, updating Jenkins jobs) is primarily I/O bound on network
connections to a Jenkins instance. However, the "parallel" name really
is misleading and could actually be harmful for users of this API who
may mistakenly have the impression that it can be used to speed up
CPU-bound tasks.
Also removes seemingly unnecessary usages of this decorator. ie,
jenkins_jobs.builder.Jenkins.changed that is never actually calle
with a list of arguments.
Change-Id: I996f9dea440e2d6b67ea70870d22942d6eef3ec7
This is the final piece of YamlParser in jenkins_jobs.builder, so also
remove the imports and make trivial fixes to test methods to prevent
borked test cases.
Change-Id: Ida543fa14c70447ae506092ec8afd5cb6caaa629
This is the first step in removing jenkins_modules.parser.YamlParser
references from jenkins_jobs.builder.Builder entirely, necessary
because load_files is actually a YamlParser behavior, not a Builder
behavior.
Change-Id: I1cad99b4cdb44af25ba398837f7f328cfcbd5bbb
This commit sees JJBConfig start to take the form it ought to have,
namely using attributes to represent different logical sections of
configuration that target specific subsystems of JJB.
It also moves ConfigParser data retrieval from
jenkins_jobs.modules.helpers.get_value_from_yaml_or_config_file() to
jenkins_jobs.config.JJBConfig.get_module_config()
TODO: Add JJBConfig tests to validate the behavior of JJBConfig in
specific circumstances.
Change-Id: I053d165559f5325a2f40b239117a86e6d0f3ef37
Explicitly encode the output of yaml dump, and allow tempfile to handle
the unicode output as it works correctly for python 2.7 and 3.x+
Change-Id: I919b2565a7f3857586ee6cc09b787160472e9deb
Ensure that cache is written to a temporary file and use an atomic OS
file rename operation to ensure that the cache is either the old
contents or new contents and cannot be corrupted by an exception
occurring during writing or should the process be killed.
Change-Id: I69947cc6d80fdc80ee7addde3a2ff87cd9c3297b
This reverts commit d1df3359b3c9fd968e8e35c51dc36b0b90ffa216.
The lockfile management code attempts to do IO on a closed file and
throws errors.
Change-Id: Ied58185758fd7c8c822624e169216441341a75d0
When a jjb run is thrown when another jjb is already running,
it can cause corruption of cache. Start using a lockfile to
ensure this won't be happening and run securely on automated
systems.
Change-Id: I3ac37e738b3bb87c04a47afb8adb3e25f8fb4ea8
The xml string needs to be encoded to utf-8
before passing it to the hash function.
Change-Id: I4b6ca7ef459b48a2ba56f788fe37307ee381ced4
Story: 2000488
getProjects() only includes simple job types like Freestyle jobs but
ignores more complex job types like Maven and Matrix jobs. This API is
also marked as deprecated in Jenkins so we probably shouldn't be using
it anyway.
Instead switch to using getAllItems() which pulls down all job types. It
is also possible to pass a parameter such as AbstractProjects or more
specific to specify exactly which job types we want to remove. In this
case though we want all of them so no need to pass any parameters.
See:
http://javadoc.jenkins-ci.org/jenkins/model/Jenkins.html
Change-Id: Ia4e37bc1d4bde70cf8f83783edd6b861eed6c2e3
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
Make sure to perform wrap external to loop, as otherwise this will
recursively wrap the output object and potentially result in getattr
lookups exceeding the recursion limit in python.
Change-Id: Ie9318a3d23a721e62c16e7b05f52d5b9bec1bb82
* Only update_jobs uses the parallel features right now
* --workers N
- If set to 0, it will use parallel execution and
use the number of cores in the machine as thread count
- Any other value enables the parallel extensions and sets the
number of concurrent threads to that value
- Will use 1 by default
Add some tests to make sure the parallel execution helpers work as
expected.
Change-Id: Ib0abd34ea7525f75fff4ff480287a6e589deba90
Signed-off-by: David Caro <dcaroest@redhat.com>
Change Ie952617a34c0719e forced utf-8 format but forgot to decode the
xml when passing to update_job. This broke jjb for python 3:
File "/Users/khaido/PycharmProjects/jenkins-job-builder
/jenkins_jobs/builder.py", line
134, in update_job
self.jenkins.create_job(job_name, xml)
File "/Users/khaido/PycharmProjects/jenkins-job-builder/.tox
/py34/lib/python3.4/site-packages/jenkins/__init__.py",
line 852, in create_job
config_xml.encode('utf-8'), DEFAULT_HEADERS))
AttributeError: 'function' object has no attribute 'encode'
Change-Id: Iceda46214bf4709ccd8141ef654cf3ec81e8af06