I have the Groovy and Groovy Postbuild plugins installed in Jenkins (1.554) and have it set to automatically install Groovy 2.2.1 when needed.
After having a problem with a constructor signature I dug a little deeper and round that Jenkins is actually using 1.8.9 by running this through the groovysh CLI.
groovy> import org.codehaus.groovy.runtime.InvokerHelper
groovy> println InvokerHelper.version
It appears that the groovy post build plugin is also using 1.8.9 based on the error message I get when I try to run my script.
How can I update this? I have already set the groovy plugin to use 2.2.1. Thanks!
Groovy Postbuild plugins use the groovy version included in Jenkins (1.8.9). You can't change it.
The problem is the same as the system script in Groovy Plugin.
If you need a newer version of groovy a workaround is to do your work in a build (like Groovy Plugin purpose). Write some informations in a text file. And Read it in Post build step to do what you want with jenkins context (create badge, add summary, etc.)
Note that you can access to build workspace in post build step with:
manager.build.project.getWorkspace()
Hope it helps.
I installed Groovy v2.4.3 to /usr/share/groovy and then in my jenkins post-build task I reference my script as /usr/bin/groovy myscript.groovy similar to how #passionne described.
Related
We have multiple testing repos, and some of the scenarios depend on the steps already created in a separate repo, so I'm trying to build the JAR file and include it in the external libraries of the other repo. Then I define my gluecode in the IntelliJ runner with two separate lines:
com.edge.automation
C:\Users\MY_NAME\.m2\repository\com\reissue-automation\2.0.3-SNAPSHOT\reissue-automation-2.0.3-SNAPSHOT-tests.jar!\com.reissue.automation.stepdefinitions
IntelliJ is able to recognize the Gherkin sentence, but when I run it, it is throwing this exception:
eissueautomationstepdefinitions'
at io.cucumber.core.options.CucumberPropertiesParser.parseAll(CucumberPropertiesParser.java:156)
at io.cucumber.core.options.CucumberPropertiesParser.parse(CucumberPropertiesParser.java:88)
at io.cucumber.core.cli.Main.run(Main.java:48)
at io.cucumber.core.cli.Main.main(Main.java:33)
Does anybody know what this error means or if it's possible to include glue code from external libraries?
I ended up running the following command to copy my dependencies into the target folder which added it to the classpath.
mvn install dependency:copy-dependencies -DskipTests
Then it picked up the glue no problem.
com.edge.automation
com.reissue.automation.stepdefinitions
If anyone has a better solution feel free to post.
May you add the detailed steps on how you accomplish it?
I tried running
mvn install dependency:copy-dependencies -DskipTests
And then running my maven command for running the test cases and not luck.
If you can add your folder structure and how you put it in the glue code of cucumber runner will be appreciated.
Also cucumber version might help.
Thanks
I writing gradle plugin for code generation, and it's use groovy org.codehaus.groovy.runtime.ExtensionModule.
But extensions resolve on gradle (daemon) start stage, and add jar with META-INF/services/org.codehaus.groovy.runtime.ExtensionModule into build script classpath has no effect.
How to register ExtentionModule manually?
I don't believe you can, as it says in the documentation:
to use an extension, it has to be available on classpath, as compiled classes, before the code using it gets compiled
Hi i'm trying to execute a groovy script inside the system Groovy script, i'm trying to import "groovyx.net.http.HTTPBuilder", unfortunately i'm getting an error - unable to resolve class groovyx.net.http.HTTPBuilder
Is there any way to use this package ?
If there is Grape support for system groovy Jenkins scripts you might try to use dependency management with Grape.
In your case it might be:
#Grab(group='org.codehaus.groovy.modules', module='http-builder', version='0.7.1')
import org.codehaus.groovy.modules.http-builder
Dependencies are getting from Maven so Master need to have Maven binary on it's configuration.
I have a Java project that has a lot of unit tests written in Groovy.I do not have the GDK installed and it still runs.
The project uses gradle and it has "apply plugin: groovy" in the build script but I was under the impression that it would just use groovyc which is definitely not installed.
How does this work?
Thanks
Inside your build.gradle file, inside the dependencies block, you will have a line probably like:
compile 'org.codehaus.groovy:groovy-all:2.4.1'
This line pulls in the specified version of groovy, and the groovy plugin uses it to compile your groovy code
I try to run my first Spock Test inside Eclipse, and it does not work.
I added all the Maven dependencies and plugins in my pom.xml, but when I run my test with jUnit, there is a popup windows with this Warning message : "No jUnit tests found".
Did you already seen this kind of message ?
What config has to be done, in order to run a Spock Test inside Eclipse ?
Thanks a lot.
Its same as running Junit test cases.
Right click on the class and run as 4Junit Test runner. see below for complete configurations and running the spock test.
Running Spock Framework with Eclipse, Gradle, Groovy: Source -
Krzysztof Goralski, blog
-Install Gradle Plugin, check it here
-Install Groovy-Eclipse for Juno or Indigo from Eclipse Marketplace (or maybe Groovy/Grails Tool Suite for Eclipse)
-Install Spock Plugin From Eclipse Marketplace if you want, check it here
-Import Project to Eclipse through Gradle Import
-Add these lines to build.gradle:
apply plugin: ‘groovy’
testCompile ‘org.spockframework:spock-spring:1.0-groovy-2.3’ (for Spring)
this is quite important, version can make some conflicts
-After this *.groovy and *.gradle files will problably looks different, Syntax colour highlightning etc. Remember that you can right click on for eg. build.gradle -> Open with -> Open With Minimalist gradle Editor etc.
-Probably you will need to make additional folder for *.groovy test files
Create new *.groovy file, class
-Basic test example, extends Specification from Spock framework and needs specific Annotations when running with Spring
-Now you can run it with JUnit from Eclipse
For integration tests you can’t use #RunWith(SpringJUnit4ClassRunner.class), and Context should looks like here #ContextConfiguration(locations = [ “/restTestContext.xml” ]) , not {} braces, but [ ]
-Spock can be used for Mocks too. Something like this: Subscriber subscriber1 = Mock() , subscriber1.isActive() >> true , So, remember >> operator for mocks.
Right click on the project > Properties > Java Build Bath > Add External Jars and add spock-core-0.6-groovy-1.8.jar and check if Groovy Libraries are there in Build Path or not. If not click on Add Library and select Groovy Runtime Libraries and restart Eclipse. Now you should be able to run. If still can't Run then try creating New Configuration and change the Test runner to Junit4 and Run it...
Check if the folder your tests are in is a source folder.