Is there any additional ant tasks(or external plugins) to convert string to lower case and trim. i got some idea by surfing, but all represents via script that has to be done. I need the manipulation should be done using ant script alone(without using java script).
Related
I'm attempting to write a global function script that uses groovy.sql.SQL.
When adding the annotation #GrabConfig(systemClassLoader=true) I get an exception when using the global function in Jenkinsfile.
Here is the exception:
hudson.remoting.ProxyException: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
General error during conversion: No suitable ClassLoader found for grab
Here is my code:
#GrabResolver(name='nexus', root='http://internal.repo.com')
#GrabConfig(systemClassLoader=true)
#Grab('com.microsoft.sqlserver:sqljdbc4:4.0')
import groovy.sql.Sql
import com.microsoft.sqlserver.jdbc.SQLServerDriver
def call(name) {
echo "Hello world, ${name}"
Sql.newInstance("jdbc:sqlserver://ipaddress/dbname", "username","password", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
// sql.execute "select count(*) from TableName"
}
Ensure that the "Use groovy sandbox" checkbox is unticked (it's below the pipeline script text box).
As explained here, Pipeline "scripts" are not simple Groovy scripts, they are heavily transformed before running, some parts on master, some parts on slaves, with their state (variable values) serialized and passed to the next step. As such, not every Groovy feature is supported.
I'm not sure about #Grab support. It is discussed in JENKINS-26192 (which is declared as resolved, so maybe it works now).
Extract from a very interesting comment:
If you need to perform some complex or expensive tasks with
unrestricted Groovy physically running on a slave, it may be simplest
and most effective to simply write that code in a *.groovy file in
your workspace (for example, in an SCM checkout) and then use tool and
sh/bat to run Groovy as an external process; or even put this stuff
into a Gradle script, Groovy Maven plugin execution, etc. The workflow
script itself should be limited to simple and extremely lightweight
logical operations focused on orchestrating the overall flow of
control and interacting with other Jenkins features—slave allocation,
user input, and the like.
In short, if you can move that custom part that needs SQL to an external script and execute that in a separate process (called from your Pipeline script), that should work. But doing this in the Pipeline script itself is more complicated.
We are using Jenkins 1.642.1 and we generate Cobertura reports for both build/deploy jobs and functional test jobs. (It appears we are using Cobertura plugin version 1.9.6) The generated report includes a link to the js source file which included red/green color coding to indicate line hits. This file includes non-ASCII characters so garbage chars are rendered in the html view of this file.
When I check the configuration of the build job (which is generated by groovy scripts) the Source Encoding setting for the 'Publish Cobertura Coverage Report' indicates "ASCII" as the setting. I need it to be UTF-8. I can choose this manually, but we don't mess with our builds manually. Everything is generated in CI style - using programming.
In this case, I see the line in the groovy script and it calls 'cobertura [path to file]'. There doesn't seem to be any room for additional arguments including that for the source encoding. Can someone point me the right direction to set this value programmatically?
Thanks,
Rob
Ah - It appears that you can micro-manage the resulting configuration.xml file via commands in your groovy file like this:
// Configuring Cobertura
project / publishers / "hudson.plugins.cobertura.CoberturaPublisher" {
coberturaReportFile('Directory path')
sourceEncoding(UTF_8)
}
I am new to JavaFX and only have some basic knowledge about Ant. At the moment I am learning how to use the FX Ant tasks to deploy an application. Edit: By using <fx:deploy nativeBundles="exe" ../> Ant automaticly uses Inno Setup to create a setup file with the .exe extension.
Since our company has some affiliated companies, most of our applications need to be deployed once for each of them. This is because some Windows Registry entries are created and they should look like this (not my idea, the management wants it to be like this!):
"HKCU\Software\affiliated company name\AppName\Settings"
Now I would like to know, if it's possible to pass a parameter from my build.xml to the .iss to insert the bold part dynamically.
I found this question , where passing
/DMyParameterName=MyValue to the Inno Setup compiler (ISC) is suggested, but I don't know how to do this from the build.xml since I can't find any direct call to the ISC.
I hope you can understand my problem (English isn't my native language). If you need more information to be able to help me please feel free to ask, I will try to add them as fast as possible.
The Java FX does not allow you to pass any additional arguments to ISCC.exe.
At least according to OpenJFX source code:
//run candle
ProcessBuilder pb = new ProcessBuilder(
TOOL_INNO_SETUP_COMPILER_EXECUTABLE.fetchFrom(params),
"/o"+outdir.getAbsolutePath(),
getConfig_ExeProjectFile(params).getAbsolutePath());
pb = pb.directory(EXE_IMAGE_DIR.fetchFrom(params));
IOUtils.exec(pb, VERBOSE.fetchFrom(params));
You might do with setting an environment variable instead of parameter and consume it using this syntax:
{%VARNAME}
See Inno Setup Constants documentation.
For those looking for a pure Ant solution (no Java FX):
The Inno Setup compiler (ISCC.exe) is a normal console executable.
You run the compiler using a basic Exec Ant task:
<project>
<exec executable="ISCC.exe">
<arg value="Example1.iss"/>
<arg value="/DMyParameterName=MyValue"/>
</exec>
</project>
I have a Groovy application that I build with Gradle. As usual I have defined the application version number/string in the build.gradle script.
Now I want to use that version string within the Groovy application, as hard-coded static piece of information. For example as a final static member in the main application class:
class MyApp {
final static APP_VERSION = "0.1"
}
Since the version information comes from the build.gradle script, that Groovy class member above needs to be set by Gradle before the sources are compiled.
In other words: I need a Gradle task that allows me to set the value of a variable in the Groovy sources, before they are built by Gradle. I could for search for that value via regular expression and replace it in the Groovy source file, but that feels a bit clunky.
Any "best practice" ideas how to achieve that?
i can't give you final solution, but, i think, you should look at AST Transformations
Another option, if you pack the application in jar / war, - you can get a version of the application from the manifest file (but it will not work if you are starting app from IDE)
final static versin = MyApp.class.getPackage().getSpecificationVersion()
How can I call a native shell script from a Groovy / Grails Application?
The shell script resides on the same machine.
Put the name (preferably with an absolute path) and the arguments in a list and call execute():
['/path/to/script', 'arg1', 'arg2'].execute()
The Groovy documentation suggests to use a simple string instead. I advise against that because it can cause all kinds of problems with special characters, white space in arguments, etc.
You can use the Groosh module (link)