parse out text from the console log, to be used in the letter stage of the build

34 views
Skip to first unread message

niristotle okram

unread,
Jul 19, 2017, 6:38:16 PM7/19/17
to jenkins...@googlegroups.com
i have the below entry in the console log.... 


     [echo] Testing the deploy
[sf:deploy] Request for a deploy submitted successfully.
[sf:deploy] Request ID for the current deploy task: 0Afg000000kyGxDCAU
[sf:deploy] Waiting for server to finish processing the request...

=====

i am trying to get this task name:  0Afg000000kyGxDCAU

so that i can use it in my build's letter stages... 


Is there a way that someone have already did this?






--
Regards

J0991

unread,
Jul 24, 2017, 5:17:58 PM7/24/17
to jenkins...@googlegroups.com
One possibility may be assigning the task name as an environment variable
during the initial job.
You could then access this environment variable from any subsequent jobs.

More information on Jenkins environment variables can be found here
<https://jenkins.io/doc/pipeline/tour/environment/> .



--
View this message in context: http://jenkins-ci.361315.n4.nabble.com/parse-out-text-from-the-console-log-to-be-used-in-the-letter-stage-of-the-build-tp4900671p4900782.html
Sent from the Jenkins users mailing list archive at Nabble.com.

niristotle okram

unread,
Jul 24, 2017, 7:03:51 PM7/24/17
to jenkins...@googlegroups.com
Well, Its not available to assign as a param ... it's something generated only when the build runs 

--
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 jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1500929850006-4900782.post%40n4.nabble.com.
For more options, visit https://groups.google.com/d/optout.
--
Sent from mobile device, excuse typos if any.

Slide

unread,
Jul 24, 2017, 8:06:20 PM7/24/17
to jenkins...@googlegroups.com
If you are running using bat or sh, you could use returnStdout to get the contents of the log (this will stop it from printing to the log I believe). Then you could parse the returned contents for the value you are looking for. See https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-sh-code-shell-script

dasauto

unread,
Jul 25, 2017, 9:03:51 AM7/25/17
to Jenkins Users
Crude but effective way:
- get current job name & build number
- wget console log from current job name & build number
- parse the text file

using env vars for current build:
wget ${JENKINS_URL}job/${JOB_NAME}/${BUILD_NUMBER}/consoleText -O  console_output.txt

niristotle okram

unread,
Jul 25, 2017, 5:00:48 PM7/25/17
to jenkins...@googlegroups.com
Thanks - the 'returnStdout' did it along with some groovy code to parse out the text from the String 

On Mon, Jul 24, 2017 at 7:05 PM, Slide <slide...@gmail.com> wrote:
If you are running using bat or sh, you could use returnStdout to get the contents of the log (this will stop it from printing to the log I believe). Then you could parse the returned contents for the value you are looking for. See https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#code-sh-code-shell-script

On Mon, Jul 24, 2017 at 4:03 PM niristotle okram <nirish...@gmail.com> wrote:
Well, Its not available to assign as a param ... it's something generated only when the build runs 
On Mon, Jul 24, 2017 at 4:17 PM J0991 <jason.lemauk@csquaredsystems.com> wrote:
One possibility may be assigning the task name as an environment variable
during the initial job.
You could then access this environment variable from any subsequent jobs.

More information on  Jenkins environment variables can be found here
<https://jenkins.io/doc/pipeline/tour/environment/>  .



--
View this message in context: http://jenkins-ci.361315.n4.nabble.com/parse-out-text-from-the-console-log-to-be-used-in-the-letter-stage-of-the-build-tp4900671p4900782.html
Sent from the Jenkins users mailing list archive at Nabble.com.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.
--
Sent from mobile device, excuse typos if any.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.

--
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 jenkinsci-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPiUgVffGCz0uDp5WFcMQfvbVzOym5D6eGq5ieK1t2z4Cy9pNw%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



--
Regards
nirish okram
Reply all
Reply to author
Forward
0 new messages