You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
By using JMeter jsr223 post processes I am trying to create ticket in Jira I have return some but that code is not working can any one help me to resolve the error is appreciated
Here is the code
import org.apache.http.HttpHeaders;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.jmeter.protocol.http.sampler.HTTPSampleResult;
def assertionResult = prev.getAssertionResults()[0]
if (assertionResult.isFailure()) {
// Set the JIRA REST API endpoint URL
String jiraUrl = "url";
// Set the JIRA account email and API token
String jiraEmail = "mailID";
String jiraApiToken = "Security token";
// Set the JSON payload for creating the JIRA ticket
String jsonPayload = """
{
"fields": {
"project": {
"key": "LEAR"
},
"summary": "Test issue",
"description": "This is a test issue",
"issuetype": {
"name": "Bug"
}
}
}
""";
// Set the HTTP headers for the JIRA REST API request
Map<String, String> headers = [:];
String authString = jiraEmail + ":" + jiraApiToken;
String encodedAuthString = authString.bytes.encodeBase64().toString();
headers.Put(HttpHeaders.AUTHORIZATION, "Basic " + encodedAuthString);
headers.Put(HttpHeaders.CONTENT_TYPE, "application/json");
// Create an HTTP client and POST request
HttpClientBuilder builder = HttpClientBuilder.create();
HttpPost post = new HttpPost(jiraUrl);
post.setHeaders(headers);
post.setEntity(new StringEntity(jsonPayload));
// Execute the JIRA REST API request and get the response
def httpResponse = builder.build().execute(post);
def responseBody = httpResponse.getEntity().getContent().text;
// Log the response details
log.info("Response code: " + httpResponse.getStatusLine().getStatusCode());
log.info("Response body: " + responseBody);
}
Thanks
hi @Satish reddy
Welcome to the community.
Could you please share the error details to better assist you with a proper solution.
Awaiting your return.
Cheers,
Karim
2023-05-17 12:30:40,533 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2023-05-17 12:30:40,534 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2023-05-17 12:30:40,534 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2023-05-17 12:30:40,764 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2023-05-17 12:30:40,825 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223 PostProcessor
javax.script.ScriptException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_202]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:45) [ApacheJMeter_components.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:955) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:573) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_202]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod.invoke(ObjectArrayGetAtMetaMethod.java:41) ~[groovy-3.0.7.jar:3.0.7]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.invoke(PojoMetaMethodSite.java:51) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.7.jar:3.0.7]
at Script62.run(Script62.groovy:11) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.7.jar:3.0.7]
... 9 more
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2023-05-17 12:30:40,827 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
2023-05-17 12:30:40,533 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2023-05-17 12:30:40,534 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2023-05-17 12:30:40,534 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2023-05-17 12:30:40,764 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2023-05-17 12:30:40,825 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223 PostProcessor
javax.script.ScriptException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_202]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:45) [ApacheJMeter_components.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:955) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:573) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_202]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod.invoke(ObjectArrayGetAtMetaMethod.java:41) ~[groovy-3.0.7.jar:3.0.7]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.invoke(PojoMetaMethodSite.java:51) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.7.jar:3.0.7]
at Script62.run(Script62.groovy:11) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.7.jar:3.0.7]
... 9 more
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2023-05-17 12:30:40,827 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi @Satish reddy
Please check parameters requirements when creating an issue using JIRA REST APIs. here you can find more info through this link. For example parameter "project" requires numeric value
Check also this Thread where you could find additional actions to help you resolve the script issue
Good Luck and let me know how it went for you.
Cheers,
Karim
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am getting this error
2023-05-17 12:30:40,533 INFO o.a.j.e.StandardJMeterEngine: Running the test!
2023-05-17 12:30:40,534 INFO o.a.j.s.SampleEvent: List of sample_variables: []
2023-05-17 12:30:40,534 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 delayedStart=false
2023-05-17 12:30:40,764 INFO o.a.j.t.ThreadGroup: Started thread group number 1
2023-05-17 12:30:40,764 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started
2023-05-17 12:30:40,764 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1
2023-05-17 12:30:40,825 ERROR o.a.j.e.JSR223PostProcessor: Problem in JSR223 script, JSR223 PostProcessor
javax.script.ScriptException: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at javax.script.CompiledScript.eval(Unknown Source) ~[?:1.8.0_202]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.extractor.JSR223PostProcessor.process(JSR223PostProcessor.java:45) [ApacheJMeter_components.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.runPostProcessors(JMeterThread.java:955) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:573) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.3]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.3]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_202]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at org.codehaus.groovy.runtime.dgmimpl.arrays.ObjectArrayGetAtMetaMethod.invoke(ObjectArrayGetAtMetaMethod.java:41) ~[groovy-3.0.7.jar:3.0.7]
at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.invoke(PojoMetaMethodSite.java:51) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139) ~[groovy-3.0.7.jar:3.0.7]
at Script62.run(Script62.groovy:11) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.7.jar:3.0.7]
... 9 more
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1
2023-05-17 12:30:40,826 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test
2023-05-17 12:30:40,827 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.