On Thu, Mar 7, 2019 at 9:29 AM Thomas Weißschuh
<[email protected]> wrote:
>> Best to not use this facility and keep each step
>> either exclusively block-scoped or non-block-scoped.
>
> Is there a chance of it breaking in the future, now that it has been published
> and documented?

I suppose not, but better not use it regardless. It was added to
support this one hack.

> It can be used to "synthesize" a step for the tracing system, which is useful
> if there is no native step with the desired scope available at the moment. […]
>
> trace(tags: ["command.type": "something"]) {
>         sh '...'
> }

Other than `Map`s not being well supported by `structs` (so for
example that `tags` syntax will be illegal in Declarative Pipeline and
would cause headaches for `Snippetizer`), this much is fine—it is akin
to `stage`, except for tags rather than display labels.

> The other syntax (without a block) allows users and pipeline library authors 
> to
> enrich the currently active tracing scope with custom information. […]
>
> # all nested steps modify the tags of the "stage" scope
> stage("someStage") {
>         # same way as above
>         trace(tags: ["foo": 1])

Would be OK if you just picked a different step name (and, as above,
avoided types not supported by Jenkins databinding).

>         # it also returns an object that can be used from groovy
>         trace().setTag("foo", 1)
>         trace().tags["bar"] = 2

Avoid these Groovy-specific idioms.

> Can you elaborate on "building something into the syntax"?
> Is it something I can already do?

Not without patching fundamental plugins, which would not be wise.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr38fhbpcJyjjwyO7t69va6iS%2BF01fGSn3AUGUWv4_O6cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to