IntelliJ code coverage runner - headless - grails

According to:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206842605-Running-IntelliJ-code-coverage-headless-on-Jenkins-
It is possible to use intellij code-coverage runner in a headless environment - i.e. Jenkins.
This is nice since IntelliJ reports much more accurate coverage results on new groovy code than e.g. Cobertura. And I can also collect information from Grails tests - unit and integration. However, I have no idea on how to set it up - gradle, maven, custom build-script or whatever - on Jenkins.
When IntelliJ runs Grails tests it fires the following command:
C:\Program Files\Java\jdk1.7.0_79\bin\java
-XX:+TieredCompilation
-XX:TieredStopAtLevel=1
-XX:CICompilerCount=3
-Dgrails.full.stacktrace=true
-Djline.WindowsTerminal.directConsole=false
-Dgrails.build.listeners=org.jetbrains.groovy.grails.rt.GrailsIdeaTestListener
-Didea.launcher.port=7533
"-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 2016.3\bin" -classpath C:\Users\xxx\AppData\Local\Temp\classpath.jar
-Dfile.encoding=UTF-8 com.intellij.rt.execution.application.AppMain org.grails.cli.GrailsCli test-app -echoOut
Which indicates that IntelliJ should be installed to run it headless. Is it possible to execute the above command in a headless env?
I have tried unpacking intellij and by executing the following (slightly modified for linux) command:
java
-XX:+TieredCompilation
-XX:TieredStopAtLevel=1
-XX:CICompilerCount=3
-Dgrails.full.stacktrace=true
-Djline.WindowsTerminal.directConsole=false -Dgrails.build.listeners=org.jetbrains.groovy.grails.rt.GrailsIdeaTestListen r
-Didea.launcher.port=7533
-Didea.launcher.bin.path=/home/jenkins/idea/bin -classpath /tmp/classpath.jar
-Dfile.encoding=UTF-8 org.grails.cli.GrailsCli test-app -echoOut
it fails with:
Error: Could not find or load main class com.intellij.rt.execution.application.AppMain even with idea_rt.jar added to the command with "cp" flag.
Is this a goose chase, or could it be done?

Did you check classpath.jar on Windows? This file is automatically generated and links lots of jars via Manifest to avoid OS limitation for the maximum command line length. Your /tmp/classpath.jar either doesn't exist or doesn't link the dependencies correctly.
Final classpath would include several IDE jars from the lib directory, project classes from the output directory and dependencies, plugin jars, etc. In other words, everything required to run the app would be linked from the generated classpath.jar file.

Related

how to run Selenium tests in Jenkins

I want to run my Selenium Webdriver Maven tests in Jenkins. I've followed the tutorial: https://www.guru99.com/maven-jenkins-with-selenium-complete-tutorial.html and https://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch04s06.html
But now, I want to run each of hundreds tests that I've written in Selenium Webdriver with Eclipse.
I use Maven to create testng.xml (where I have my Maven projects to can execute a list of tests in the same execution).
I use Eclipse to write Java to create tests in Selenium Webdriver.
I use github to import tests.
I show you my github project... I don't know how to access into the different folders to execute each testng.xml files, sorry, I'm pretty new here.
Could anybody help me with this issue?
Thanks so much!!!!
Create a freestyle Jenkins job and then go to the configuration page of your job and in Source Code Management section add the URL of your Git repo where you have kept your TestNG tests. This will help to bring the tests from the repository to your workspace.
Then go to the Build section and select Execute windows batch script if and then add the following script:
java -cp ".;/path/to/testng-x.x.x.jar;/path/to/jcommander-x.xx.jar;/path/to/test-classes" org.testng.TestNG /path/to/test.xml
For Linux use the following script with Execute shell in `Build step:
cd /path/to/test.xml
java -cp "/path/to/testng-x.x.x.jar:/path/to/bin" org.testng.TestNG testng.xml
Where /bin folder contains the compiled code for the TestNG tests.
Then save the job and run the build to execute TestNG test cases.
Note: You can find the required JAR files inside the .m2 folder.

How do I analyze Groovy code with Sonarlint for IntelliJ?

The Sonarlint plugin for IntelliJ does analysis on our Java code, but it won't analyze Groovy code in the same project.
We have a Grails project which works with sonar-runner on the command line. When I install the IntelliJ IDEA Sonarlint plugin, the plugin doesn't seem to pick up the settings from our command line config, and it doesn't show the warning highlights for issues like it does for the Java files in the editor.
Our project uses the "code-coverage" Grails plugin to generate an XML coverage report, then the sonar runner (command line tool) pulls in the metrics. In sonar-project.properties, we set:
# Project key within sonar
sonar.projectKey=com.mycompany:myapp
sonar.projectName=My Grails Project
sonar.projectVersion=1.0
# Source directories to analyze
sonar.sources=src/groovy, grails-app/domain, grails-app/services, grails-app/controllers, grails-app/utils, grails-app/taglib, grails-app/views
# Set language for the project to be Groovy
sonar.language=grvy
# Path to the Cobertura XML report
sonar.grvy.coveragePlugin=cobertura
sonar.groovy.cobertura.reportPath=target/test-reports/cobertura/coverage.xml
sonar.jdbc.username=...
sonar.jdbc.password=...
sonar.host.url=http://sonar.mycompany.com
sonar.jdbc.url=...
sonar.jdbc.driverClassName=...
The properties file has JDBC settings, the coverage report path, etc.
SonarLint is a different product than SonarQube (even if there are some links). For example SonarLint doesn't know what is sonar-project.properties. The purpose is to integrate with IntelliJ, not with some external configuration.
Regarding Groovy support, this is not planned since we don't have any Groovy analyzer (the SonarQube plugin for Groovy is simply reusing codenarc reports AFAIK). If you want to run Codenarc in IntelliJ, there is already a dedicated plugin for that.

grails 3 run-app fails due to file permissions set by perforce VCS

TLDR:
I have a Grails 3 project. The run-app command was working fine. Then I checked it into Perforce. Now run-app fails.
DETAILS:
Grails Version: 3.1.1
Groovy Version: 2.4.5
JVM Version: 1.8.0_91
Gradle 2.13
% grails clean
BUILD SUCCESSFUL
% grails run-app
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':processResources'.
Could not copy file '/Volumes/Neo/singram/work/code/depot/dvdco/webapplications/nightcrawler/grails-app/i18n/messages.properties' to '/Volumes/Neo/singram/work/code/depot/dvdco/webapplications/nightcrawler/build/resources/main/messages.properties'.
GUESS at cause:
Perforce, when a file isn't checked out for editing, will make that file non-writable (chmod a-w). As best I can tell, run-app invokes gradle's processResources which successfully copies the file in question once, then seemingly attempts to copy it again during the same build cycle and fails because thew newly copied file is not writable so it cannot be overwritten with a copy of itself.
WORK-AROUND
The run-app command succeeds if I check out the whole project for editing first. Don't really want to have to do this as it introduces opportunity for error during check-ins.
QUESTION:
Is there a better way than my work-around? Why is gradle's processResources copying the same files more than once? Is there some sort of hook into processResources or run-app that I can use to "chmod -R u+w build" ?
A couple of options, methinks. Either 1) change the filetype(s) (if Perforce-controlled) to +w to make them writable; or 2) change the workspace spec to include the "allwrite" option to make all files writable. –

Grails 2.5.1: use grails command-line tasks from binary plugin in lib folder

In Grails 2.5.1, is it possible to use grails command-line tasks from a binary plugin in the lib folder?
I had to modify an existing third-party plugin to get it to work properly.
I put the jar generated by the following command in my project's lib directory:
grails package-plugin --binary
When my project runs, it correctly uses my modified version of the plugin.
At build time, however, I need to run a Grails task on the command line that was provided by the plugin, but, using the binary plugin, the task does not appear to be available.
e.g., if the task was abc, when using the real plugin being referenced in the plugins section of BuildConfig.groovy, then I could run:
grails abc
Using the binary plugin in the lib folder, however, results in the task not being available from the command line.
Also, the original plugin hooked into grails war to include extra steps in the build process without changing the command line. These hooks no longer run with the binary plugin. Is there any way to reinstate the hooks for the binary plugin?
Thanks.

Can't run DynaForm - BUILD FAILED - Ant

To run the sample application of DynaForm (a dynamic web form generator) I followed the readme instruction:
DynaForm - a dynamic web form genrator
To run the sample application use your command line and type "ant".
Then open localhost:2000/ on your browser.
The build script requires ANT and JDK (at least Java 1.6) to be in the path.
The DynaForm's project site is hostet at:
http://code.google.com/p/xsd-web-forms/
Rein Raudjärv
May 23 2010
In my Mac I have ANT and JDK (with Java 1.6). When launch in my command line "ant" I have this error:
BUILD FAILED
/Users/colet/Desktop/dynaform/build.xml:64: /Users/colet/Desktop/dynaform/${env.ANT_HOME}/lib does not exist.
Maybe I misunderstood the sentence:
The build script requires ANT and JDK (at least Java 1.6) to be in the path.
what does "to be in the path" mean?
Thanks!
Please clone the DynaForm project from GitHub instead of Google Code:
https://github.com/reinra/dynaform
The newer version builds via Maven instead of Ant, so it's simpler and should work better.
Check that you have defined ANT_HOME environment variable correctly. Refer to Ant installation instructions, if needed.

Resources