Logging Agent Information to consoleLog of Build

22 views
Skip to first unread message

Andreas Sieferlinger

unread,
Jan 13, 2020, 8:32:00 AM1/13/20
to Jenkins Developers
Hey,

i'm currently working on extending the Amazon ECS plugin a little bit to add some information about the agent the job is run on the the builds log in the UI.
For example the assumption was that the following line would create such a log entry:

As i learned on gitter (thanks btw to the people helping there) that this is happening in a different context, and therefore is most likeley ending up in the agents log.

Do you see another way of providing information about the Agent within the build log (eg somehow listening for builds and then trying to resolve that information)?

Thx for your help :)

Ullrich Hafner

unread,
Jan 13, 2020, 10:59:44 AM1/13/20
to Jenkins Developers
Am 13.01.2020 um 14:18 schrieb Andreas Sieferlinger <psdsief...@gmail.com>:

Hey,

i'm currently working on extending the Amazon ECS plugin a little bit to add some information about the agent the job is run on the the builds log in the UI.
For example the assumption was that the following line would create such a log entry:


I never used the launcher extension point but from the code link it looks that the method launch is invoked on the master so the lister messages should end up in the log of the corresponding node. (http://localhost:8080/computer/[your-agent]/log)
Typically, a TaskListener reports the progress on the master... 
 
As i learned on gitter (thanks btw to the people helping there) that this is happening in a different context, and therefore is most likeley ending up in the agents log.

Do you see another way of providing information about the Agent within the build log (eg somehow listening for builds and then trying to resolve that information)?

Thx for your help :)

--
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 jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/fbc6cdf5-6e3d-41c5-baa2-bf00548298b0%40googlegroups.com.

Andreas Sieferlinger

unread,
Jan 14, 2020, 10:26:43 AM1/14/20
to jenkin...@googlegroups.com
Yep, afaik they do. The problem in this context is that due to the agents being ephemeral they are deleted immediately after they stop, and with that also this log is gone.
So the idea was to add some basic output (eg the TaskID) in the actual build log for easier debugging for users.

So far I haven't found a way how I would put that information into the consoleLog per build for every node being spawned

You received this message because you are subscribed to a topic in the Google Groups "Jenkins Developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-dev/peQPWLwdsT0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/E43976B8-6093-4461-953A-51ECBEFCBE3A%40gmail.com.

Jesse Glick

unread,
Jan 14, 2020, 12:11:27 PM1/14/20
to Jenkins Dev
On Tue, Jan 14, 2020 at 10:26 AM Andreas Sieferlinger
<psdsief...@gmail.com> wrote:
> The problem in this context is that due to the agents being ephemeral they are deleted immediately after they stop, and with that also this log is gone.
> So the idea was to add some basic output (eg the TaskID) in the actual build log for easier debugging for users.

Reminds me of: https://github.com/jenkinsci/kubernetes-plugin/pull/497

In general, diagnostics for ephemeral agents are not great. If you use
for example the `dockerNode` step, then the Jenkins queue is bypassed
and the agent log is just streamed into the owning build log. I do not
think there is a simple way for `Computer` (etc.) implementation to
inject this into the log for a user of the general `node` step or
freestyle builds, though. The best I can come up with (Pipeline only)
is to implement

https://javadoc.jenkins.io/plugin/workflow-api/org/jenkinsci/plugins/workflow/flow/StepListener.html

then check whether it is `node` (`ExecutorStep`) being run, and if the
context says that the `Computer` is yours, ask the context for the
`TaskListener` and copy the `Computer.getLogText` so far. Ideally
there would be a real API for a computer to print some information
when a build starts using an executor on it; or some flag indicating
that it is ephemeral and single-use so that the code using the
executor (e.g., `ExecutorStepExecution`) could decide to stream the
agent log.

Andreas Sieferlinger

unread,
Jan 15, 2020, 9:45:02 AM1/15/20
to Jenkins Developers
I hoped there would be an easier way, but i'll try if i can figure it out for the ECS plugin
Reply all
Reply to author
Forward
0 new messages