Getting Data In

How do I get RobotFramework tags into Splunk via Jenkins plugin?

JykkeDaMan
Path Finder

I have the Splunk Jenkins plugin in use, but I cannot find the RobotFramework test tags from the raw data.

Should I do some custom configurations into Jenkins side so that it would add the test level RobotFramework tags into the testcase data?

Below in an example from the Robot results.

Is the plugin sending only the "Test results", but not "Robot Results" to the Splunk?

Screenshot 2020-10-26 at 20.59.40.jpg

Currently I can find only the following test level results from the Splunk.

 

{ [-]
         classname: Testsuites.Assistant tests.Configurations
         duration: 307
         errordetails: *HTML* ...
         errorstacktrace:
         failedsince: 329
         groupname: Testsuites
         skipped: false
         status: FAILURE
         testname: Assistant For External Callers
         uniquename: Testsuites.Assistant tests.Configurations.Assistant For External Callers
}

 

Labels (1)
0 Karma
1 Solution

JykkeDaMan
Path Finder

I managed to get it like this:

import hudson.plugins.robot.RobotBuildAction
import com.splunk.splunkjenkins.utils.LogEventHelper

def build=splunkins.build
def robotAction=build.getAction(RobotBuildAction)
if(robotAction) {
    def robotResults=[]
    def allTestCases = robotAction.result.suites[0].getAllCases()
    allTestCases.each { test ->  
            robotResults << ["name" : test.getRelativePackageName(), "tags":test.tags, "duration":test.duration,
             "passed": test.passed, "description":test.description]
       }
    def metadata = LogEventHelper.getBuildVariables(build)
    def robotData = ["metadata":metadata, "build_url":build.url, "robot_results":robotResults, "build_number": build.number]
    splunkins.send(robotData)
}

View solution in original post

0 Karma

Ted
Engager
import hudson.plugins.robot.RobotBuildAction
import com.splunk.splunkjenkins.utils.LogEventHelper

def build=splunkins.build
def robotAction=build.getAction(RobotBuildAction)
if(robotAction) {
    def robotResults=[]
    robotAction.result.suites.each { suite ->
       suite.caseResults.each { result ->  
            robotResults << ["name" : result.name, "tags":result.tags, "duration":result.duration,
             "passed": result.passed, "description":result.description]
       }
    }
    def metadata = LogEventHelper.getBuildVariables(build)
    def robotData=["metadata":metadata, "build_url", build.url, "robot_results":robotResults]
    splunkins.send(robotData)
}

you can insert the code sample snippet into the plugin config -> Advance ->Customize Event Processing Command 

it will send an extra event into jenkins index

P.S. the tag is not a standard field, the Jenkins app will not show it, you need build your own dashboard

JykkeDaMan
Path Finder

Thanks, I was hopping something like this.

I fixed a minor typo in

 

 

"build_url", build.url -> "build_url":build.url

 

 

I tried it, but I got empty results like this:

 

 

{ [-]
   build_url: job/658/
   metadata: { [-]
     scm: git
   }
   robot_results: [ [-]
   ]
}

 

 

0 Karma

JykkeDaMan
Path Finder

I managed to get it like this:

import hudson.plugins.robot.RobotBuildAction
import com.splunk.splunkjenkins.utils.LogEventHelper

def build=splunkins.build
def robotAction=build.getAction(RobotBuildAction)
if(robotAction) {
    def robotResults=[]
    def allTestCases = robotAction.result.suites[0].getAllCases()
    allTestCases.each { test ->  
            robotResults << ["name" : test.getRelativePackageName(), "tags":test.tags, "duration":test.duration,
             "passed": test.passed, "description":test.description]
       }
    def metadata = LogEventHelper.getBuildVariables(build)
    def robotData = ["metadata":metadata, "build_url":build.url, "robot_results":robotResults, "build_number": build.number]
    splunkins.send(robotData)
}
0 Karma

JykkeDaMan
Path Finder
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Get Agentic with Splunk Lantern: Connect to Cisco Cloud Control, Transform ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...

July Community Events: Master ITSI 5.0 & Automate Splunk

Struggling with alert fatigue or feeling like you're spending more time on infrastructure maintenance than ...

New Release of Federated Search: Bringing Splunk Analytics to More of Your Data

Organizations today are generating more data than ever and storing it across cloud object stores, data lakes, ...