Merge lp:~joetalbott/ci-core-jenkins/fix_release_channel_sep into lp:ci-core-jenkins

Proposed by Joe Talbott
Status: Merged
Approved by: Joe Talbott
Approved revision: 14
Merged at revision: 13
Proposed branch: lp:~joetalbott/ci-core-jenkins/fix_release_channel_sep
Merge into: lp:ci-core-jenkins
Diff against target: 35 lines (+7/-6)
1 file modified
jenkins/setup-jobs.py (+7/-6)
To merge this branch: bzr merge lp:~joetalbott/ci-core-jenkins/fix_release_channel_sep
Reviewer Review Type Date Requested Status
Paul Larson Approve
Francis Ginther Approve
Review via email: mp+257305@code.launchpad.net

Commit message

Make trigger url a command line option.

This makes overriding for strange channel and release combined channel
names easier.

Description of the change

Make trigger url a command line option.

This makes overriding for strange channel and release combined channel
names easier.

To post a comment you must log in.
Revision history for this message
Paul Larson (pwlars) wrote :

Assumptions like this tend to get fragile. I wonder if we should just make the trigger something that we specify in the config for the channel?

Revision history for this message
Francis Ginther (fginther) wrote :

copy isn't a supported method on str :-(.

$ ./setup-jobs.py -n --series wily --channel rolling_edge --device-type generic_amd64 --publish
Traceback (most recent call last):
  File "./setup-jobs.py", line 220, in <module>
    main()
  File "./setup-jobs.py", line 166, in main
    triggerurl = _trigger_url(args.channel, args.device_type)
  File "./setup-jobs.py", line 153, in _trigger_url
    rel_channel = channel.copy()
AttributeError: 'str' object has no attribute 'copy'

I'm also thinking Paul has a good idea. If we just add a '--url' parameter, we can just avoid this inconsistent behavior the usage of channel names.

review: Needs Fixing
Revision history for this message
Francis Ginther (fginther) wrote :

Alternately, we can keep using the _trigger_url() method and just drop the copy() and "maxsplit=". This is working for me with this arguments:

./setup-jobs.py -n --series wily --channel rolling_edge --device-type generic_amd64 --publish

14. By Joe Talbott

Make trigger url a command line option.

This makes overriding for strange channel and release combined channel
names easier.

Revision history for this message
Francis Ginther (fginther) wrote :

Looks good, thanks for fixing.

review: Approve
Revision history for this message
Paul Larson (pwlars) wrote :

One minor thing, otherwise +1

review: Approve
Revision history for this message
Joe Talbott (joetalbott) wrote :

On Fri, May 08, 2015 at 07:29:55PM -0000, Paul Larson wrote:
> Review: Approve
>
> One minor thing, otherwise +1
>
> Diff comments:
>
> > === modified file 'jenkins/setup-jobs.py'
> > --- jenkins/setup-jobs.py 2015-04-09 18:09:29 +0000
> > +++ jenkins/setup-jobs.py 2015-05-08 19:13:15 +0000
> > @@ -46,6 +46,7 @@
> > help="URL of jenkins instance to configure test in")
> > parser.add_argument("-c", "--channel", default=CHANNEL,
> > help="Channel for the job to define on")
> > + parser.add_argument("-t", "--trigger-url", help="Trigger url for the job")
> > parser.add_argument("--device-type", default=DEVICE,
> > help="Device type for the job")
> > parser.add_argument("-b", "--branch", default="lp:ci-core-jenkins",
> > @@ -141,18 +142,18 @@
> > return False, str(err)
> >
> >
> > -def _trigger_url(channel, device):
> > - return 'http://system-image.ubuntu.com/ubuntu-core/%s/%s/index.json' \
> > - % (channel, device)
> > -
> > -
> > def main():
> > parser = get_parser()
> > args = parser.parse_args()
> > setup_logging(args.debug)
> >
> > instance = login_jenkins(args.jenkins, args.username, args.password)
> > - triggerurl = _trigger_url(args.channel, args.device_type)
> > + triggerurl = (
> > + "http://system-image.ubuntu.com/ubuntu-core/%s/%s/index.json" %
> > + (args.channel, args.device_type)
>
> Why not just set that as the default for the arg?

I'm not certain it would work if, for example the user added --channel
but not url then the url wouldn't have the proper channel set. At least
that's my understanding of how argparse works. I could and very well
may be wrong. I'll do some digging.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jenkins/setup-jobs.py'
2--- jenkins/setup-jobs.py 2015-04-09 18:09:29 +0000
3+++ jenkins/setup-jobs.py 2015-05-08 19:13:15 +0000
4@@ -46,6 +46,7 @@
5 help="URL of jenkins instance to configure test in")
6 parser.add_argument("-c", "--channel", default=CHANNEL,
7 help="Channel for the job to define on")
8+ parser.add_argument("-t", "--trigger-url", help="Trigger url for the job")
9 parser.add_argument("--device-type", default=DEVICE,
10 help="Device type for the job")
11 parser.add_argument("-b", "--branch", default="lp:ci-core-jenkins",
12@@ -141,18 +142,18 @@
13 return False, str(err)
14
15
16-def _trigger_url(channel, device):
17- return 'http://system-image.ubuntu.com/ubuntu-core/%s/%s/index.json' \
18- % (channel, device)
19-
20-
21 def main():
22 parser = get_parser()
23 args = parser.parse_args()
24 setup_logging(args.debug)
25
26 instance = login_jenkins(args.jenkins, args.username, args.password)
27- triggerurl = _trigger_url(args.channel, args.device_type)
28+ triggerurl = (
29+ "http://system-image.ubuntu.com/ubuntu-core/%s/%s/index.json" %
30+ (args.channel, args.device_type)
31+ )
32+ if args.trigger_url:
33+ triggerurl = args.trigger_url
34
35 logging.info('Series: ' + args.series)
36

Subscribers

People subscribed via source and target branches