On Tue, Mar 21, 2017 at 10:02 AM, ishan jain <[email protected]> wrote:
> Probably i am being silly, but seriously i am not able to call a function
> which i have defined in my Jenkinsfile from within a step. Here is a sample:
>
> def meta = "something"
>
> stage (build) {
>
>       buildProject(meta)
> }
>
> def buildProject(meta) {
> return {
>       node {
>           //whatever i need to do
>       }
>   }
> }

I might be wrong, but I don't believe you can use the "node" or
"stage" DSL anywhere but in the main body of the script.

> This simply does not do anything. I tried various combos to try n call it,
> but nothing. How exactly should i call a function ?

Calling a function is simple.  Did you try having the function just do
a "println" or "echo" to verify that it got there?  If you see that,
then move on to more complex functionality.

> def meta = "something"
>
> stage (build) {
>       node {
>       buildProject(meta)
>   }
> }
>
> def buildProject(meta) {
> return {
>
>           //whatever i need to do
>
>   }
> }
>
>
>
> def meta = "something"
>
> stage (build) {
>       step {
>       buildProject(meta)
>      }
> }
>
> def buildProject(meta) {
> return {
>       node {
>           //whatever i need to do
>       }
>   }
> }
>
>
>
> def meta = "something"
>
> stage (build) {
>
>       def output =  buildProject(meta)
> }
>
> def buildProject(meta) {
> return {
>       node {
>           //whatever i need to do
>       }
>   }
> }
>
> --
> 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/1cf8438c-7bc4-44f6-9e1d-3f42ee863de2%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/CAA5t8VoV1HK%3Du2L0bje1goh5hNHNcWicj2zK78DxwO0RD%3D2pwQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to