LogParserPublisher rules on slave

359 views
Skip to first unread message

jer...@bodycad.com

unread,
Jan 24, 2017, 4:11:22 PM1/24/17
to Jenkins Users
Hi,

I'm trying to use this pipeline command on my Windows slave node:

step([$class: 'LogParserPublisher', parsingRulesPath: all_rules_file, useProjectRule: false, failBuildOnError: true, unstableOnWarning: true, showGraphs: true]);

I get the following error:
ERROR: Failed to parse console log

java.io.FileNotFoundException: c:\Jenkins\workspace\MyProject@tmp\all_rules.txt (No such file or directory)


The file is created at runtime on the slave, it's there and filled properly and permission are correct. I was wondering, if I invoke the step LogParserPublisher command, does it get run on the master even if declared inside the slave node? do I have to stash/copy the rules files back to the master? then do a new node('master') at the end?

if so I will have to send the email after this, so my ig try catch will overlap 2 node, is that legal code? and the email will get send by the master instead I suppose

Right now I have

node('windows')
{
try
{
...
step([$class: 'LogParserPublisher', parsingRulesPath: all_rules_file, useProjectRule: false, failBuildOnError: true, unstableOnWarning: true, showGraphs: true]);
...
}
catch(any)
{
currentBuild.result = 'FAILURE'
throw any //rethrow exception to prevent the build from proceeding
}
finally
{
emailext ...
}
}

What I should do to have the LogParserPublisher done back on the master, but doesn't seem like ligit code:

try
{
node('windows')
{
...
stash includes: "all_rules.txt", name: 'MyRules'
...
}

node('master')
{
def tempo_dir = pwd([tmp: true])
dir(tempo_dir)
{
unstash name: 'MyRules'
step([$class: 'LogParserPublisher', parsingRulesPath: "${tempo_dir}/all_rules.txt", useProjectRule: false, failBuildOnError: true, unstableOnWarning: true, showGraphs: true]);
}
}
}
catch(any)
{
currentBuild.result = 'FAILURE'
throw any //rethrow exception to prevent the build from proceeding
}
finally
{
node('master')
{
// I need a node to perform command here but...
emailext ...
}
}


how does one get to send an email if anything failed from any node actions?

Daniel Beck

unread,
Jan 26, 2017, 9:37:39 AM1/26/17
to jenkins...@googlegroups.com

> On 24.01.2017, at 22:11, jer...@bodycad.com wrote:
>
> I was wondering, if I invoke the step LogParserPublisher command, does it get run on the master even if declared inside the slave node? do I have to stash/copy the rules files back to the master? then do a new node('master') at the end?
>
> if so I will have to send the email after this, so my ig try catch will overlap 2 node, is that legal code? and the email will get send by the master instead I suppose

The Pipeline is run on the master, with only specific calls being transferred to the agent and resulting in execution of something there.

This is no different from e.g. Freestyle projects: They are also actually executed on master, and plugins need to take special steps to have happen what users expect (e.g. look in actual workspace on agent). So that should all be transparent to you as user, unless the plugin developer doesn't follow the developer guidance on distributed builds.[1]

1: https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds

jer...@bodycad.com

unread,
Jan 26, 2017, 9:50:08 AM1/26/17
to Jenkins Users, m...@beckweb.net
Yeah, seem about right, this what I end up doing:

def all_rules_file = 'rules.txt'
dir(pwd([tmp: true]))
{
writeFile([file: all_rules_file, text: all_rules_str]);
stash includes: all_rules_file, name: 'LogParsingRules'
}
node('master')
{
unstash 'LogParsingRules'
step([$class: 'LogParserPublisher', parsingRulesPath: "${env.WORKSPACE}/${all_rules_file}", useProjectRule: false, failBuildOnError: true, unstableOnWarning: true, showGraphs: true]);
}

So I create the temp file on the slave then stash it, move to the master, unstash iit then run the LogParserPublisher there. It would probably work if step() is executed on the slave through.


Daniel Beck

unread,
Jan 26, 2017, 10:07:33 AM1/26/17
to jenkins...@googlegroups.com

> On 26.01.2017, at 15:50, jer...@bodycad.com wrote:
>
> It would probably work if step() is executed on the slave through.

Not necessary, but you're telling it to run on the master. From reading the code, something like the following should do:

…, useProjectRule: true, projectRulePath: "${env.WORKSPACE}/${all_rules_file}", …

Jérôme Godbout

unread,
Jan 26, 2017, 10:11:55 AM1/26/17
to jenkins...@googlegroups.com
what's the difference between the projectRulePath and parsingRulesPath exactly? I though the project was the one set into the master config, but I may totally be wrong about this. The API is confusing.

Would also be nice to call this per stage console output, so I don't parse the huge build / unit tests output for a small parts. I would also avoir having to concat each stage parsing rules as I go and wait at the end to kick in the console parsing with each stage rules.

I would love to have multiple output for console log parsing per project.

bodycad
Jerome Godbout
Software Developer
2035 rue du Haut-Bord, Québec, QC, Canada. G1N 4R7
T:  +1 418 527-1388
E: jer...@bodycad.com
www.bodycad.com

The contents of this email message and any attachments are intended solely for the addressee(s) and may contain confidential and/or privileged information and may be legally protected from disclosure. If you are not the intended recipient of this message or their agent, or if this message has been addressed to you in error, please immediately alert the sender by reply email and then delete this message and any attachments. If you are not the intended recipient, you are hereby notified that any use, dissemination, copying, or storage of this message or its attachments is strictly prohibited. 

Le contenu de ce message et les pièces jointes sont destinés uniquement pour le(s) destinataire(s) et peuvent contenir des informations confidentielles et / ou privilégiées qui peuvent être protégées légalement contre toute divulgation. Si vous n'êtes pas le destinataire de ce message ou son agent, ou si ce message vous a été adressé par erreur, s’il vous plaît avertir immédiatement l'expéditeur par courriel de réponse, puis supprimer ce message et les pièces jointes. Si vous n'êtes pas le destinataire prévu, vous êtes par la présente informé que toute utilisation, diffusion, copie, ou stockage de ce message ou de ses pièces jointes est strictement interdit.



--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/LqCZZeShThU/unsubscribe.
To unsubscribe from this group and all its topics, 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/717F5CAA-79EE-404C-9409-50D8856B21C6%40beckweb.net.
For more options, visit https://groups.google.com/d/optout.

Daniel Beck

unread,
Jan 26, 2017, 10:14:49 AM1/26/17
to jenkins...@googlegroups.com

> On 26.01.2017, at 16:11, Jérôme Godbout <jer...@bodycad.com> wrote:
>
> what's the difference between the projectRulePath and parsingRulesPath exactly? I though the project was the one set into the master config, but I may totally be wrong about this. The API is confusing.

To be honest, I don't know. I just noticed that one uses the workspace, the other a path on the Jenkins master. Maybe your use case is even unsupported.

Reply all
Reply to author
Forward
0 new messages