[JIRA] (JENKINS-57248) How to create an influxdb target for jenkins pipeline project?

2 views
Skip to first unread message

sridattasp@gmail.com (JIRA)

unread,
Apr 30, 2019, 8:14:03 AM4/30/19
to jenkinsc...@googlegroups.com
sridatta s created an issue
 
Jenkins / Bug JENKINS-57248
How to create an influxdb target for jenkins pipeline project?
Issue Type: Bug Bug
Assignee: Aleksi Simell
Components: influxdb-plugin, pipeline
Created: 2019-04-30 12:13
Priority: Major Major
Reporter: sridatta s

Jenkins pipeline 2.150.2 
InfluxDB 1.6.2

I want to create a influx db target from jenkins pipeline project. I went through the document mentioned at https://wiki.jenkins.io/display/JENKINS/InfluxDB+Plugin

Steps:

1. Created a pipeline project

2. In the pipeline block, I have below code as per the help doc

 

 def influxdb = Jenkins.instance.getDescriptorByType(jenkinsci.plugins.influxdb.DescriptorImpl)
 
// Create target
def target = new jenkinsci.plugins.influxdb.models.Target()
 
// Set target details
// Mandatory fields
target.description = 'jenkins_data'
target.url = 'http://127.0.0.1:8086'
target.username = 'admin'
target.password = ''
target.database = 'jenkins_data'
// Optional fields
target.exposeExceptions = true // default = true
target.jobScheduledTimeAsPointsTimestamp = true // default = false
target.usingJenkinsProxy = true // default = false
target.retentionPolicy = 'autogen' // default = 'autogen'
// NEW in version 1.20.1
//target.replaceDashWithUnderscore = true // default = false
 
// Add a target by using the created target object
influxdb.addTarget(target)
influxdb.save()
 
// Write stuff to InfluxDB
// NOTE! If you have more targets configured in Jenkins, it's safer to add "selectedTarget" parameter to the InfluxDB step to ensure
// data is sent to the correct target.
// step([$class: 'InfluxDbPublisher', target: 'myNewTarget', selectedTarget: 'myNewTarget', customPrefix: 'myPrefix', customData: myDataMap])
def myDataMap = [:]
myDataMap['myKey'] = 'myValue' 
step([$class: 'InfluxDbPublisher', target: 'jenkins_data', selectedTarget: 'jenkins_data', customPrefix: 'myPrefix', customData: myDataMap])
// Remove a target by using the target description field value
influxdb.removeTarget("jenkins_data")
influxdb.save()
println "saved"

 

 

3. Build the project and I see below error in console output

Console output: 

org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing
Perhaps you forgot to surround the code with a step that provides this, such as: node
 at org.jenkinsci.plugins.workflow.steps.StepDescriptor.checkContextAvailability(StepDescriptor.java:261)
 at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:260)
 at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:176)

 

Any suggestions would be really helpful?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

aleksi.simell@eficode.com (JIRA)

unread,
Jun 27, 2019, 2:59:02 AM6/27/19
to jenkinsc...@googlegroups.com
Aleksi Simell commented on Bug JENKINS-57248
 
Re: How to create an influxdb target for jenkins pipeline project?

Are you still facing this issue? Have you put the step inside a node as the error message suggests?

node {
    // Define target
    // ...
    // Publish data
}

aleksi.simell@eficode.com (JIRA)

unread,
Sep 5, 2019, 1:41:02 AM9/5/19
to jenkinsc...@googlegroups.com
Aleksi Simell closed an issue as Cannot Reproduce
 

Not enough information to reproduce this, closing issue.

Change By: Aleksi Simell
Status: Open Closed
Resolution: Cannot Reproduce
Reply all
Reply to author
Forward
0 new messages