groovy

Programmatically getting Jenkins configuration for a plugin

旧城冷巷雨未停 提交于 2020-06-24 12:53:16
问题 I'm trying to get (and hopefully change) the Jenkins configuration for a plugin with a Groovy script inside the Groovy console. My specific example is to try to change multiple IP addresses for the publish-over-ssh plugin. It's pretty easy to do via the command line (editing the xml), but after hours of struggling with it, I'd still like to find how it would be done via the groovy console, for no other reason than the enlightenment. I've looked through the Jenkins API javadoc, but to no avail

Gradle/Groovy syntax confusion

自古美人都是妖i 提交于 2020-06-23 04:45:47
问题 Can anyone explain/comment on this fraction of Groovy code? task copyImageFolders(type: Copy) { from('images') { include '*.jpg' into 'jpeg' } from('images') { include '*.gif' into 'gif' } into 'build' } More specifically about the from method. Is this the from(sourcePaths) or the from(sourcePath, configureAction) If its the one with the 2 arguments, why it’s written this way and not something like: from('images', { include '*.jpg' into 'jpeg' }) 回答1: The short answer is it's calling from

Is there any way to automatically setting windows path in a string in groovy?

家住魔仙堡 提交于 2020-06-17 09:17:08
问题 My project root directory is: D:/Project/Node_Project I am using a gradle plugin to install nodejs temporarily in my project root directory so that some nodejs command can run in the project while the thoject builds. The plugin is as below: plugins { id "com.github.node-gradle.node" version "2.2.4" } node { download = true version = "10.10.0" distBaseUrl = 'https://nodejs.org/dist' workDir = file("${project.buildDir}/nodejs") } So, nodejs is getting installed inside the project in the

Calling internal methods of Jenkins plugin (thinBackup)

谁说我不能喝 提交于 2020-06-16 05:57:11
问题 I need to call internal functions of some Jenkins plugins that do not seem to be exposed via Jenkins CLI or remote api. For example, one of them is thinBackup and I'd like to call restore method avialable at https://github.com/jenkinsci/thin-backup-plugin/blob/master/src/main/java/org/jvnet/hudson/plugins/thinbackup/restore/HudsonRestore.java . Is this possible using Java or Groovy (or any other method really, the simpler, the better)? 回答1: You can set up dependencies between plugins as

How to pass command line argument to Gradle Kotlin DSL

时间秒杀一切 提交于 2020-06-12 04:44:00
问题 Here's an example from Groovy that represents exactly what I would like to achieve: Command line : ./gradlew jib -PmyArg=hello build.gradle.kts task myTask { doFirst { println myArg ... do what you want } } Source of this example is here - option 3. How can I read pass and read myArg value in Kotlin DSL ? 回答1: After some time found an answer: build.gradle.kts val myArg: String by project // Command line argument is always a part of project task("myTask") { doFirst { if (project.hasProperty(

How to pass command line argument to Gradle Kotlin DSL

£可爱£侵袭症+ 提交于 2020-06-12 04:42:08
问题 Here's an example from Groovy that represents exactly what I would like to achieve: Command line : ./gradlew jib -PmyArg=hello build.gradle.kts task myTask { doFirst { println myArg ... do what you want } } Source of this example is here - option 3. How can I read pass and read myArg value in Kotlin DSL ? 回答1: After some time found an answer: build.gradle.kts val myArg: String by project // Command line argument is always a part of project task("myTask") { doFirst { if (project.hasProperty(

Using failFast with closure map breaks “parallel” step

梦想的初衷 提交于 2020-06-10 07:36:02
问题 Not sure if it's my limited knowledge of Groovy or a quirk in Pipeline parallel step. I can't make it accept failFast if I use map instead of passing each closure individually: def map = [:] map['spam'] = { node { echo 'spam' } } map['eggs'] = { node { echo 'eggs' } } parallel map // Works. parallel spam: map['spam'], eggs: map['eggs'], failFast: true // Works. parallel map, failFast: true // Fails with exception. The exception with failFast is: java.lang.IllegalArgumentException: Expected

Is there a way to list all gradle dependencies programmatically?

旧时模样 提交于 2020-06-09 07:56:32
问题 I know that doing: gradle dependencies Lists the full dependency tree. Now, I'm looking for a way to manipulate that dependencies tree programmatically so that I can print the same hierarchy but in JSON instead of the format the gradle cli uses right now in the console. Which are the groovy classes I should use to achieve that? EDITED I would like to obtain (in JSON) some like this: "dependencies" : [ { "groupId" : "com.something", "artifactId" : "somethingArtifact", "version" : "1.0",

Mocked instance of final class in Spock behaves differently in test and dev code

匆匆过客 提交于 2020-06-09 04:12:53
问题 In my JavaFX application I am using Spock and Groovy for testing. I have dedicated WebBrowserController for taking care of my JavafX WebView component. I wanted to test some functionalities that depend on current Location and Document of the WebView . Relevant part of WebBrowserController: public WebEngine getEngine() { return panel.getWebView().getEngine(); } This is how I create an instance of WebBrowserController for my tests. Notice the GroovyMock I used there - ordinary Mock(...) does

Apache Nifi 1.6: crash Groovy script

喜你入骨 提交于 2020-06-01 06:20:14
问题 In Apache Nifi parse xml in json. On local machine with limited data set my code work. In full data set, on server Apache Nifi, when JSON is collect, some values lead to errors. Full script: import groovy.json.* import org.apache.commons.io.IOUtils import java.nio.charset.StandardCharsets import org.apache.nifi.processor.io.StreamCallback def get_map(Node) { nodeRootName = Node.name() if (Node.childNodes().size() == 0) { return [(nodeRootName): (Node.text())] } else { subMap = [(nodeRootName)