Bug #2519

${next-value} and non-string values

Added by J. Moringen over 8 years ago. Updated over 7 years ago.

Status:ResolvedStart date:03/13/2016
Priority:NormalDue date:
Assignee:J. Moringen% Done:


Category:Processing Model
Target version:0.8


Original report: https://opensource.cit-ec.de/issues/474

ich habe mal ein paar issues in Form eines Beispiels gesammelt:
Die letzten 3 commits in https://opensource.cit-ec.de/projects/citk/repository?utf8=%E2%9C%93&rev=buildgen-bugs sind:
  • 683ade4 setting repository cleanup behaviour 58 minutes ago Robert Haschke
    Die Verwendung von booleans mit ${next-value|...} funktioniert leider nicht. Der String evaluiert dann immer zu true.

Associated revisions

Revision b669c4b6
Added by J. Moringen over 7 years ago

Added value casting protocol in src/project/{protocol,variable-evaluation}.lisp

refs #2519

  • src/project/protocol.lisp (as): new generic function; cast a value to
    a given type
    (as :around t t): new method; error behavior
    (as t t): new method; default behavior
  • src/project/variable-evaluation.lisp (as t eql boolean): new method;
    behavior for `boolean' type
    (as t cons): new method; behavior for `or' and `eql' types
  • src/project/package.lisp (package jenkins.project): added exported
    symbol as; added shadowed symbol as
  • src/report/package.lisp (header): updated copyright
    (package jenkins.report): added shadowing-import-from jenkins.project
    symbol as
  • src/commandline-interface/package.lisp (header): updated copyright
    (package jenkins.project.commandline-interface): added
    shadowing-import-from jenkins.project symbol as

Revision 4249784c
Added by J. Moringen over 7 years ago

Made variable value accesses typed in src/project/aspect[s].lisp

fixes #2519

  • src/project/aspect.lisp (make-aspect-class-form): generate local
    function var/type that performs casts via `as'
  • src/project/aspects.lisp (define-aspect parameters): use `var/typed'
    instead of `var'
    (define-aspect retention): likewise
    (define-aspect jdk): likewise
    (define-aspect redmine): likewise
    (define-aspect redmine-and-git): likewise
    (define-aspect archive): likewise
    (define-aspect git): likewise
    (define-aspect subversion): likewise
    (define-aspect mercurial): likewise
    (define-aspect trigger/scm): likewise
    (define-aspect timeout): likewise
    (define-aspect tasks): likewise
    (define-aspect slaves): likewise
    (define-aspect dependency-download): likewise
    (define-aspect cmake/unix): likewise
    (define-aspect archive-artifacts): likewise
    (define-aspect maven): likewise
    (define-aspect setuptools): likewise
    (define-aspect warnings): likewise
    (define-aspect xunit): likewise
    (define-aspect junit): likewise
    (define-aspect email-notification): likewise
    (define-aspect debian-package): likewise
    (define-aspect debian-package/cmake): likewise
    (define-aspect upload): likewise


#1 Updated by J. Moringen over 8 years ago

The problem is that in ${next-value|DEFAULT}, DEFAULT can only be a string unless it is a variable reference.

Solutions could be:

  1. Requiring JSON-syntax in DEFAULT, but that seemed insane to me at the time. Consider for example
    "name": "${next-value|[ \"foo${bar|\\\"baz\\\\"}\", true ]}" 
  2. Special treatment of some strings in DEFAULT (and elsewhere?), i.e.
    ${next-value|true}  => true
    ${next-value|troo}  => "troo" 
    ${next-value|false} => true
    ${next-value|fawls} => "fawls" 

    but that would make it impossible to specify the string "true" and in a very surprising way, too.
  3. Work around the issue
    "false": false ; <- define in some very basic template
    "name": "${next-value|${false}}" 

    (I didn't have time to try this, but it should work)

#2 Updated by R. Haschke over 8 years ago

You could simply "cast" the type from string to boolean at the final stage, where you know that a boolean is required.
If that is successul, fine. Otherwise, issue an error.

Anyway, I will try your third option tomorrow.

#3 Updated by J. Moringen over 7 years ago

  • Target version set to 0.8

#4 Updated by J. Moringen over 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF