the problem is that you are not running the code as Groovy script, you include the code in your pipeline script, it is not the same.
save this as a Groovy script in your repo, something like scripts/my-testlink.groovy #!/usr/bin/env groovy import testlink.api.java.client.TestLinkAPIResults.* import testlink.api.java.client.TestLinkAPIClient.* def DEVKEY = "1f123453b123bd8dd811a7f824c194d0" def URL = "http://PC4/lib/api/xmlrpc/v1/xmlrpc.php <http://pc4/lib/api/xmlrpc/v1/xmlrpc.php>" def api = new TestLinkAPIClient(DEVKEY, URL) TestLinkAPIResults projects = api.getProjects() api.createTestProject(...) then use it on your pipeline ``` node(){ sh(label: 'my script', script:'./scripts/my-testlink.groovy') } ``` El lun., 15 abr. 2019 a las 11:39, Marogo Ytcutc (<marogo2...@gmail.com>) escribió: > Still doesn't work. :-( I will describe what I have done in turn. > I downloaded the file "testlink-api-client-2.0.zip" from: > > https://code.google.com/archive/p/dbfacade-testlink-rpc-api/downloads > > After extract archive I placed the file "testlink-api-client-2.0.jar" in > directory "D:\Jenkins\testlink\" > > In the configuration of my job in Jenkins I marked the option "Prepare an > environment for the run" > and set "Properties Content" to: > > CLASSPATH=D:\\Jenkins\\testlink > > My pipeline code in Jenkins job: > > #!/usr/bin/env groovy > import groovy.json.JsonSlurper > import testlink.api.java.client.TestLinkAPIResults.* > import testlink.api.java.client.TestLinkAPIClient.* > > node('PC-2') > { > ansiColor('xterm') > { > try > { > echo "CLASSPATH: " + env.CLASSPATH > def DEVKEY = "1f344123b456bd9dd822a7f824c194c3" > def URL= "http://TestLinkPC/lib/api/xmlrpc/v1/xmlrpc.php" > def api = new TestLinkAPIClient(DEVKEY, URL) > } > catch(e) > { > String error = "${e}"; > currentBuild.result = 'FAILURE' > emailext body: "Log: ${env.BUILD_URL}console", recipientProviders: > [[$class: 'FirstFailingBuildSuspectsRecipientProvider'], [$class: > 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider'], [ > $class: 'UpstreamComitterRecipientProvider']], subject: "Build > #${env.BUILD_NUMBER} of job ${env.JOB_NAME} finished with status: > ${currentBuild.currentResult}" > } > } > } > > In console log I received an error: > > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > WorkflowScript: 22: unable to resolve class TestLinkAPIClient > @ line 22, column 18. > def api = new TestLinkAPIClient(DEVKEY, URL) > ^ > > Where is the problem? > > > > W dniu sobota, 13 kwietnia 2019 23:38:38 UTC+2 użytkownik Marogo Ytcutc > napisał: >> >> Thank You very much for Your help! I will check it on Monday. >> >> W dniu sobota, 13 kwietnia 2019 21:09:40 UTC+2 użytkownik Ivan Fernandez >> Calvo napisał: >>> >>> Put the jar file in a folder inside the classpath of the JDK used by >>> your agent >> >> -- > 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/70qz8g46LpQ/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > jenkinsci-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jenkinsci-users/9f8c7cc0-66e5-4411-89e2-c384158d0131%40googlegroups.com > <https://groups.google.com/d/msgid/jenkinsci-users/9f8c7cc0-66e5-4411-89e2-c384158d0131%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Un Saludo Iván Fernández Calvo https://www.linkedin.com/in/iv%C3%A1n-fern%C3%A1ndez-calvo-21425033 -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAKo5Qrq8U%2B6Xfso47S6nh3syaUxm9g_Jyza2xDEN5pYohzE_iQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.