how to use execute() in groovy to run any command

I usually build my project using these two commands from command line (dos) G:\> cd c: C:\> cd c:\my\directory\where\ant\exists C:\my\directory\where\ant\exists> ant -Mysystem ... ..... build...

How to define private getter method in Groovy Bean?

I used following code. class Bike{ def manufacturer; private getManufacturer(){ manufacturer } } But I was able invoke getter method from another class.

Can I change my Windows desktop wallpaper programmatically in Java/Groovy?

Is there a way I can use Java (or Groovy) to change my desktop wallpaper in Windows XP? I have a program that creates a new image every day (or whenever) and I would like a way to automatically...

How to detect the current OS from Gradle

I found this answer about how to do it with Groovy: https://stackoverflow.com/questions/4689240/how-to-detect-the-platform-window-or-linux-by-groovy-grails: if...

What is the difference between project(':projectName') {} and $projectRoot/projectName/build.gradle

I see reference to a subproject as project(':projectName') {} inside $projectRoot/build.gradle and I also see reference to a subproject with a seperate build such as...

How to move an element to the first position of a List in groovy

how do I reorder the list say: ['apple', 'banana', 'orange'] if user select banana, the list becomes ['banana', 'apple', 'orange']

Git hook, modify commit files

I'm trying to write a Git pre-commit hook script. It should write the date of commit at the beginning of modified files. My problem is that I can't add modified files to the previous commit. When...

How to list classpath for tests in Gradle

When I try running gradle test, I get the following output: $ gradle test :ro:compileJava UP-TO-DATE :ro:processResources UP-TO-DATE :ro:classes UP-TO-DATE :ro:jar :compileJava :processResources...

Groovy Swingbuilder: How can i add a scrollpanel to my frame?

I want to add a scrollpane, which contains a textarea, but I don't know how. So I searched the internet and found some examples, but none of them helped me. This is some of my code: frame =...

Error while executing groovy script

Code is a follows: class Book { private String title Book (String theTitle) { title=theTitle } String getTitle() { return title } } Book...

How do I list all of my Jenkins credentials in the script console?

I'm trying to get Jenkins to clone my mercurial project from BitBucket. It won't, because it says there's a problem with the credentials - well, bitbucket is refusing whatever it is that Jenkins...

Grails clean command throwing Null Pointer Exception

We are planning to upgrade Grails for our application from version 2.0.1 to 3.1.1. On executing grails clean --stacktrace --verbose I am getting the exception given below: | Error...

How to pass boolean parameter value in pipeline to downstream jobs?

I'm using Jenkins v2.1 with the integrated delivery pipeline feature (https://jenkins.io/solutions/pipeline/) to orchestrate two existing builds (build and deploy). In my parameterized build I...

How to list all `env` properties within jenkins pipeline job?

Given a jenkins build pipeline, jenkins injects a variable env into the node{}. Variable env holds environment variables and values. For example, environment variable BRANCH_NAME can be accessed...

Elasticsearch Scripting: updating array value

This is my document { "name": "andrew", "b": [{"x":"c1", "y": 0}, {"x":"c2", "y": 0}] } I want to find element in the array field "b" and update the entire object. I tried this script...

Gradle NoClassDefFoundError when running jar

I'm trying to set up a Gradle project with some Velocity functions in it. So far I have the following files: **src/main/java/com/veltes/velotest.java:** package com.veltes; import...

How to add new configuration with Gradle Kotlin-dsl

with gradle-groovy it is possible to create a new configuration with: configurations { explode } dependencies { explode (group: 'org.apache.samza', name: 'samza-shell', ext: 'tgz',...

How to print Groovy list and keep the quotes?

We have a list: List test = ["a", "b", "c"] I don't want to alter this list hardcoded, since it has many items. When printing this like: println "${test}" We get [a, b, c] but I want to have...

How can I force Jenkins Blue Ocean to display print output instead of "Print Message"?

In the below screenshot some debug entries display the output text (with - Print Message at the end) while others simply display Print Message. To view these you have to expand the step to see the...

Information-hiding in Groovy (using closures? naming conventions?)

This follows from my unsuccessful attempt to find an answer to this question from 2014. It's not clear to me whether there might in fact be some techniques in Groovy to use closures, specifically,...

How to pass credential binding in environment directive conditionally

This doesn't work: environment { Pass = "${blah == 'yes' ? credentials('somecred') : credentials('otherCred')}" I can set an env var to credentials() directly but when trying to use the...

Gradle: Could not determine java version from '11.0.2'

I ran the following comment: ./gradlew app:installDebug only to be met with the log: FAILURE: Build failed with an exception. * What went wrong: Could not determine java version from...

is there a way to specify a constructor for a groovy script?

I have a groovy script called Foo.groovy, an instance of that script can be constructed using the following syntax: def foo = new Foo() i know if Foo.groovy looks like: import...

@MicronautTest does not start the embedded server

I am writing a Spock test for controllers in an app using Micronaut. When using @MicronautTest(application=Application), it throws exception with message @MicronautTest used on test but no bean...

helm hosted repo via CLI

I installed the helm repo plugin for nexus3 Now I want to create the helm hosted repo via RestAPI command, in the same way as I do for raw repository # RAW Repository curl -X POST...

mainClassName not found which is not needed

I am creating a library which doesn't have a main class at all. The library uses Spring which has application plugin which is looking for mainClassName. I added mainClassName with null, but I am...

Read csv and Print matched text using Jenkins declarative Pipeline Script

currently Im working on jenkins declarative pipeline scripting it would be great if I can get some help with the scripting below. I have 10 CSV files in a location. I want to open each file and...

Why does using mockito-junit-jupiter and mockito-inline together in Groovy, results in InvalidUseOfMatchersException?

I have a problem with using mockito-junit-jupiter and mockito-inline together in my groovy code, for testing static classes and methods. Hopefully someone can help me. My current situation is: I...

How to fix "unsupported class file major version 60" in IntelliJ?

I have a Gradle project in Ubuntu. It's written in Java 14. I have the Java 14 JDK installed. When I build it from the command line, everything works, but no one wants to use a command line! ...

Springfox Swagger 2.9.2 Incredibly Slow with Spring Boot 2.5.x With Groovy 3

I have a Spring Boot 2.4.4 project with Springfox 2.9.2. When I upgrade to Spring Boot 2.5.3, my servers cannot start: the Swagger scanning takes forever and a day and (I think) exhausts the...