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

[Jenkins] supporting the new folder naming convention #1442

Merged
merged 4 commits into from
Mar 18, 2015

Conversation

hkaj
Copy link
Member

@hkaj hkaj commented Mar 17, 2015

Starting from v1.597, the build folder names are not named with a timestamp anymore but with an ID. We have to get the timestamp from the build.xml file and to use the folder name to guess the build number.

@hkaj hkaj changed the title Haissam/jenkins new folder format [Jenkins] supporting the new folder naming convention Mar 18, 2015
# versions of Jenkins > 1.597 need to be sorted by build number (integer)
try:
dirs = sorted(dirs, key=lambda x: int(x.split('/')[-1]), reverse=True)
except:
Copy link

Choose a reason for hiding this comment

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

You should almost never use bare "except:" as it would also catch System exiting exceptions which you don't want.

You should use except Exception or even better catch the actual exceptions that can be raised here.

@hkaj hkaj force-pushed the haissam/jenkins-new-folder-format branch from ce5334d to 756ed60 Compare March 18, 2015 15:24
build_file = os.path.join(dir_name, 'build.xml')

if not os.access(build_file, os.R_OK):
self.log.debug("Can't read build file at %s" % (build_file))
Copy link

Choose a reason for hiding this comment

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

You don't need this line

@remh
Copy link

remh commented Mar 18, 2015

One last thing is that now you'll parse the build.xml twice.

One to get the timestamp and one to get the other metadata, can you consolidate this ?

Looks good otherwise!

@hkaj hkaj force-pushed the haissam/jenkins-new-folder-format branch from bac7616 to 26acdb3 Compare March 18, 2015 18:02
# We try to get the last valid build
for index in xrange(0, len(dirs) - 1):
for index in xrange(len(dirs)):
Copy link

Choose a reason for hiding this comment

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

Nice bug fix!
We should likely just do:

for dir_name in dirs:

unless i'm missing something ?

@hkaj hkaj force-pushed the haissam/jenkins-new-folder-format branch from 26acdb3 to f223822 Compare March 18, 2015 18:23
@hkaj hkaj force-pushed the haissam/jenkins-new-folder-format branch from f223822 to 5bc5224 Compare March 18, 2015 18:23
remh pushed a commit that referenced this pull request Mar 18, 2015
[Jenkins] supporting the new folder naming convention
@remh remh merged commit a1596ec into master Mar 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants