Eventually I managed to trigger a job with a specific label at the
pipeline-build-step via NodeLabel Parameter Plugin you mentioned.
So thanks again, Michael. The way you proposed works fine.
Maybe the actual way I did this can be useful for someone.
The correct way is presented at the Pipeline DSL code snippet:
build job: 'job2',
parameters: [
[
$class: 'LabelParameterValue',
name: 'NODE_NAME',
label: 'label1'
]
]
The difference with my previous try is at the name of the 3rd Groovy
map-entry at the Pipeline DSL code snippet above. The actual key for this
map-entry when using the NodeLabel Parameter Plugin should be 'label' and
not 'value'. This is due the constructors of LabelParameterValue:
https://github.com/jenkinsci/nodelabelparameter-plugin/blob/nodelabelparameter-1.7.2/src/main/java/org/jvnet/jenkins/plugins/nodelabelparameter/LabelParameterValue.java
---- the 2nd parameter at the constructors where the 2nd parameter is
presented has name 'label' and not 'value'. And the logic of constructor
parameter passing when ParameterValue objects are created is a comparison
of a map-entry key with a Java-code constructor parameter name:
https://github.com/jenkinsci/structs-plugin/blob/structs-parent-1.5/plugin/src/main/java/org/jenkinsci/plugins/structs/describable/DescribableModel.java
---- see methods
instantiate(Map<String, ?> arguments)
and
buildArguments(Map<String,?> bag, Type[] types, String[] names, boolean
callEvenIfNoArgs)
Thus it seems quite obscure how to compose a map corresponding to a
parameter of plugin (especially due lack of documentation) until one will
look into the actual code of a corresponding ParamValue subclass.
For instance for StringParameterValue (for any simple parameterized job)
the 2nd parameter is 'value' (and not 'label').
Hope it will help someone.
This helped me to workaround the inability to build job via
pipeline-build-step with node assigned by a pipeline through 'node (..)
{..}'-clause.
Best regards,
Alexander.
On Wednesday, December 14, 2016 at 3:42:09 PM UTC+3, mpapo - Michael
Pailloncy wrote:
>
>
> If you want to trigger job1 with a specific label, you should have a look
> to this plugin :
> https://wiki.jenkins-ci.org/display/JENKINS/NodeLabel+Parameter+Plugin
> However, I never used it inside a Jenkins Pipeline.
>
>
--
You received this message because you are subscribed to the Google Groups
"Jenkins Users" 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-users/b18a5c53-05f4-4e94-809f-f340d254fcfb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.