Hi Slide,

Thanks for the inputs.
I did check the value of output its returning always 1, actually it has
value 0. not sure why?

one more clarification can we call awk  in script { } block ?

regards
Somshekar


Regards
Somshekar C Kadam
9036660538

On Thu, Apr 19, 2018 at 7:12 PM, Slide <[email protected]> wrote:

> Ok, then my suggestion is fine, after readFile, the variable output has
> the value, so just use an if check directly in the script block of the
> pipeline. script blocks are groovy scripts, so you can use most of the
> functionality of groovy to do what you want.
>
> On Thu, Apr 19, 2018 at 6:24 AM Somshekar C Kadam <[email protected]>
> wrote:
>
>> Hi Slide,
>>
>> You got it right.
>>
>> result file contains either 0 or 1 as a unittest pass or fail.
>> I need to read this file which contains 0 or 1 and proceed next stage.
>>
>> thanks in advance
>> regards
>> Somshekar
>>
>> Regards
>> Somshekar C Kadam
>> 9036660538 <(903)%20666-0538>
>>
>> On Thu, Apr 19, 2018 at 6:52 PM, Slide <[email protected]> wrote:
>>
>>> Well, it depends on what you are expecting to happen with these lines:
>>>
>>> awk '{ if ($1 == 0 ) { $res = "passed" } else $res = "fail" }' result
>>>
>>> awk '{ if ($1 == 0 ) { print "Success"; } else print "failure" }' result
>>>
>>>
>>> The shell scripts don't take parameters, so what are you expecting to be
>>> in $1? What does the variable output contain? Will it contain the 0 or
>>> other exit code? If so, just use an if statement in the script {} block to
>>> check the value
>>>
>>> script {
>>>     ...
>>>     output = readFile 'result'
>>>     if(output == "0") {
>>>
>>>     } else {
>>>
>>>    }
>>>
>>> }
>>>
>>>
>>>
>>> On Thu, Apr 19, 2018 at 6:15 AM Somshekar C Kadam <[email protected]>
>>> wrote:
>>>
>>>> Hi Slide,
>>>>
>>>> First of thanks for the response. Ok understood
>>>>  Am not finding any documentation to do the same in jjenkinsfile.
>>>> Please can you point to it or any example will help
>>>>
>>>> regards
>>>> Somshekar
>>>>
>>>> Regards
>>>> Somshekar C Kadam
>>>> 9036660538 <(903)%20666-0538>
>>>>
>>>> On Thu, Apr 19, 2018 at 6:39 PM, Slide <[email protected]> wrote:
>>>>
>>>>> You can't set res inside a shell script and have it set in the
>>>>> pipeline. It seems like you are trying to use shell scripts to do things
>>>>> that could be done directly in the Jenkinsfile as well. Is there a reason
>>>>> you are using shell scripts for that?
>>>>>
>>>>> On Thu, Apr 19, 2018 at 1:41 AM Somshekar <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> Hi All,
>>>>>>
>>>>>> I am trying to change the value of string dependign upon the unittest
>>>>>> cases passed by reading a file.
>>>>>> For next stage to proceed I want to set the string depending upon the
>>>>>> value next stage qa or other stage can proceed.
>>>>>> but not able to change value f string in jenkins file.
>>>>>>
>>>>>> value of res is not changing at all
>>>>>>
>>>>>> also to verify I have added one more script block belwo it to verify
>>>>>> if able to read file proerly and its value, its working fine.  below its
>>>>>> printing failure as value is set to 1 in result file.
>>>>>>
>>>>>> not sure on this, please let me know possible solution thanks in
>>>>>> advance
>>>>>>
>>>>>> =====================
>>>>>> environment {
>>>>>>                         res = 'pass'
>>>>>>                         qapass  = 'fail'
>>>>>>                         output  = '-1'
>>>>>>                 }
>>>>>>
>>>>>> ....
>>>>>> ....
>>>>>>
>>>>>>  script {
>>>>>>                             output = readFile 'result'
>>>>>>                             echo "Value of output is $output"
>>>>>>                             echo 'inside the script'
>>>>>>                             sh '''
>>>>>>                                 awk '{ if ($1 == 0 ) { $res =
>>>>>> "passed" } else $res = "fail" }' result
>>>>>>                                 echo 'outside the script'
>>>>>>                                 echo "value is $res"
>>>>>>                              '''
>>>>>>                         }
>>>>>>  script {
>>>>>>                             sh '''
>>>>>>                                 awk '{ if ($1 == 0 ) { print
>>>>>> "Success"; } else print "failure" }' result
>>>>>>                                 echo 'outside the script'
>>>>>>                              '''
>>>>>>                         }
>>>>>>
>>>>>> ==========================
>>>>>>
>>>>>> --
>>>>>> 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/8b5e5fd5-8e6f-486f-aa54-
>>>>>> f5bc97aa1f03%40googlegroups.com
>>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/8b5e5fd5-8e6f-486f-aa54-f5bc97aa1f03%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> 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/CAPiUgVfvD%3DhiFmw2-RcTZhAV%3D0UAfX1VGMYdG%2B4%
>>>>> 2BNyMq5rNp4Q%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVfvD%3DhiFmw2-RcTZhAV%3D0UAfX1VGMYdG%2B4%2BNyMq5rNp4Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>
>>>>
>>>>> 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/CALbGK-q3d-9vOVGcviqS6JqnKU0U669ey7Dw7irV
>>>> kZNL7XSqoQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/jenkinsci-users/CALbGK-q3d-9vOVGcviqS6JqnKU0U669ey7Dw7irVkZNL7XSqoQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> 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/CAPiUgVfz8KEM9KS7Q2VP5RAai0%
>>> 3D6KY1Dbig_1mvTs1T6wDNa1A%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVfz8KEM9KS7Q2VP5RAai0%3D6KY1Dbig_1mvTs1T6wDNa1A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>
>>
>>> 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/CALbGK-ps-XRJaG-R7jsPC-%
>> 2BbD3nZu4NJEpkJYsyA_cCT5rgrBA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/jenkinsci-users/CALbGK-ps-XRJaG-R7jsPC-%2BbD3nZu4NJEpkJYsyA_cCT5rgrBA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> 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/CAPiUgVdy-67daooVFrLtk-wgtCt6YpJzCtGWREGK7ucBXcxq5Q%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVdy-67daooVFrLtk-wgtCt6YpJzCtGWREGK7ucBXcxq5Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> 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/CALbGK-pEz3eeJD8vUsJh4zqoZPzW4m%3DGYCPxEYtCDZ7pfpH1ag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to