Jenkins: Logfile location on agent nodes?
Asked Answered
J

3

12

I have a jenkins controller-agent setup through JNLP connections. Everything is working fine except I can not find any logs on the agent nodes. There are logs on the controller in $JENKINS-HOME/logs/slaves but none on the agent node.

Can you tell me on which path the log is or if there is even logging on the slave node?

Juneberry answered 25/1, 2019 at 9:50 Comment(0)
S
14

Jenkins stores all logs on the controller only, that's why you cannot find any log on nodes.

Softcover answered 25/1, 2019 at 11:10 Comment(2)
While this answer is accurate, it isn't helpful. The original question and intents is "where is the log for the slave" You've simply said on the master, but forgot to identify where on the master.Cornered
@JohnRocha I didn't clarify where, because author already mentioned it in the question: 'There are logs on the master in "$JENKINS-HOME/logs/slaves"'. So I don't know why you think that my answer isn't helpful.Softcover
L
4

On Windows, the agent stores error logs in the same folder as the agent.jar file. This reports things like:

Dec 19, 2018 2:38:14 PM hudson.remoting.Engine waitForServerToBack

"INFO: Failed to connect to the master. Will retry again".

That message will never appear be uploaded to the Controller.

I would like to see a similar log file on other agents.

Labiate answered 15/11, 2019 at 16:22 Comment(2)
You might need to add the -workDir or -agentLog argument to the java command line. As that link says: "Before Remoting 3.8 (Jenkins 2.68)... Logs are not being persisted to the disk unless -agentLog option is specified." See the link for more docs.Kab
@Kab Can we set global environmental variables JENKINS_JAVA_OPTS or JAVA_OPTS (github.com/jenkinsci/remoting/blob/master/docs/logging.md) to redirect slave agent logs to STDOUT? I'm trying to get all logs to container logs rather than to master node? Is it possible? (#74588966) ThanksDisaffection
B
2

They are mostly transferred to Master by TCP. For example, when a step starts, like a shell task, will do like this

  1. call your shell content
# your script will be transform into a script file
script.sh > jenkins-log.txt
# running...
# after running
echo $? > jenkins-result.txt
  1. during the running progress, data will be transport by TCP(pull or push)
jenkins-log.txt -> Filestream -> RemoteStream -> Master

and in master, you will see single log like it

jobs/xxx/branch/master/<id>/log
  1. When job is done, master will send the command to clean the temp dir in the agent, so you can't see anything about logs.

One more thing, in our company, we are facing the problem of too much logs are being sent to Master like a DDOS, so a simple way to solve is to add a pipeline after the shell

limit by tail

xxx | tail -c 512k 

or limit the size by head command

xxx | (head -n 1000;dd status=none of=/dev/null)
Benitobenjamen answered 16/8, 2019 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.