I followed all the instructions in the top answer here
But when I associate a file as "Groovy" I see the "no candidates found for method call" on all the groovy commands like "pipeline", "environment", etc in my groovy scripts.
I tried downloading the groovy SDK from apache as well as brew, but both result in the same issue.
Related
How do I setup a Rascal-MPL project to consume the DSL built with Rascal?
I don't seem to find any resource that details how to solve that particular problem
The documentation hasn't been written for that case but here goes:
Use newRascalProject from util::Reflective to create a basic setup. For both the DSL project and the consuming project that makes sense.
mvn install in the DSL project, if you won't have the DSL project folder open in Eclipse or VScode or if you are working bare bones Unix/Maven.
In RASCAL.MF of the client project add Require-Libraries: |lib://dsl-project|
In pom.xml of the client project add a dependency on the DSL jar.
Restart the console or terminal for a file of the client project.
In the terminal the active version of the path configuration for the interpreter will be printed. It should have the DSL project in the list of srcs.
In VScode log for the Rascal LSP you can see the path configuration printed when compiling/checking source files in the client project. There the DSL project should be in the libs path.
If the DSL project isn't compiled to .tpl files that appear in the target folder and eventually in the jar, you will get spurious error messages in the client code. In that case trigger the compiler in the DSL project by saving the top module, or run mvn install again. Revisit the pom file for the settings of the rascal-maven-plugin
For those landing at this page and trying to find an example of calling newRascalProject with working parameters...
The first parameter is a 'location'. While it is documented how to use this parameter (https://www.rascal-mpl.org/docs/Rascal/Expressions/Values/Location/), it still took my some time to figure out that a location is not a regular string, and not using double quotes " but |.
So if you try:
newRascalProject ("home:///Projects/rascal_playground", "hello2")
You get the following error:
Advice: |https://www.rascal-mpl.org/docs/Rascal/Errors/CompileTimeErrors/UndeclaredVariable/UndeclaredVariable.html|
Including the variable name for the 2nd parameter...
newRascalProject ("home:///Projects/rascal_playground", name="hello")
... gives the same error.
This is the correct example:
newRascalProject (|home:///Projects/rascal_playground|, name="hello")
So I am having trouble uploading our dotCover results from Jenkins to our Sonar instance. We are using the SonarScanner for MSBuild plugin. All of the documentation I have found like here: https://docs.sonarqube.org/pages/viewpage.action?pageId=6389770#CodeCoverageResultsImport(C#,VB.NET)-dotCover
Shows how to do it from the command line. We are using the plugin. There is an area for additional arguments that I have added what I assume is an added argument like on the command line. Here is how I have it set up:
So that is the argument that everything shows to add to the end of the command line portion, but for some reason it doesn't add coverage to Sonar. Does anyone see anything obvious I am missing here? I have been stuck on this for a while. Thanks!!
So as it turns out I had:
/d:sonar.cs.dotcover.reportsPath=
It should have been with an s at the end:
/d:sonar.cs.dotcover.reportsPaths=
In my Jenkins build, I have a Groovy script(because I am using the Pipeline plugin) where I am trying to make an API call using OkHttpClient.
I have the following Grape code that I got from here:
#Grapes(
#Grab(group='com.squareup.okhttp', module='okhttp', version='2.7.5')
)
For this, I am getting:
General error during conversion: Error grabbing Grapes -- [unresolved dependency: com.squareup.okkhttp#okhttp;2.7.5: not found]
java.lang.RuntimeException: Error grabbing Grapes -- [unresolved dependency: com.squareup.okhttp#okhttp;2.7.5: not found]
at sun.reflect.NativeContructorAccessorImpl.newInstance0(Native Method)
Any idea what could be wrong?
Can't Grape retrieve packages when running in a Jenkins pipeline script?
I had a similar issue running a Jenkins Groovy console script that used the #Grab annotation. The error was caused by the Jenkins Groovy not being able to resolve my corporate proxyhost server.
The Groovy proxyserver can be set on the command line, like this:
groovy -Dhttp.proxyHost=yourproxy -Dhttp.proxyPort=portNumber yourscript.groovy
but I was not able to find out how to do that for the Jenkins Groovy.
I ended with the following workaround:
You can install the required library from the command line (assuming you have access to the Jenkins server). In that case the proxyserver is easily specified as follows:
grape -Dhttp.proxyHost=proxy.server.net -Dhttp.proxyPort=port install %groupId% %artifactId% [%version%]
Also insure that you install the library while logged in under the Jenkins user account. Grapes libraries are user account specific.
Documentation for the Groovy Plugin of Jenkins states that
The system groovy script, OTOH, runs inside the Jenkins master's JVM.
Thus it will have access to all the internal objects of Jenkins, so
you can use this to alter the state of Jenkins. It is similar to the
Jenkins Script Console functionality.
Yet I find that I have a groovy script that I can successfully run in Jenkins Script Console but which does NOT run if entered as a "System Groovy Script" on a build configuration. There are compiler errors. Clearly, the Jenkins Script Console is running with a different classpath than the script in my build. But I can't find information on what the default classpath is when running a script for a build or what the classpath is when running from the Script Console, so I might duplicate that for my script.
Also, the plugin offers a classpath entry field for running the script as a file but that option does not exist for entering the script as text.
I can't get my script to work either way.
What am I missing?
I think the answer is that the Script Console auto-imports the whole Jenkins library. That is not the case with the System Groovy Script. So what worked for me was to run the script, and for every compiler error about an unknown class, add an import statement for that class. I learned what packages they were from by looking at Javadocs.
Automating this would be a nice improvement to the plugin.
May be use the grab dependency management to resolve the library to add
I am unable to link java classes when using the rascal shell interpreter. This the error message that I receive:
unexpected error: Cannot link method org.my.MyClass because: class not found
Using Eclipse's rascal shell works. Tried with both stable (0.8.0.201510190912) and unstable (0.8.0.201606061752) versions
I assume you are running the release jar using java -jar rascal-<version>.jar, then the only safe way I know how is to pack your Rascal sources and the necessary class files into the jar with the rest of Rascal. You might also try and extend the java classpath with the -cp option to java.