groovy

How to pass JVM arguments and script argument using GroovyShell?

耗尽温柔 提交于 2021-01-28 19:12:08
问题 So I have a Groovy script: // TestScript.groovy println args Then in a Gradle task I have test { String profile = System.getenv("spring.profiles.active") jvmArgs '-Dspring.profiles.active=$profile" // THIS DOES NOT WORK! :( doLast { new GroovyShell().run(file('package.TestScript.groovy')) } } What I need to do is two things: a) Pass into TestScript.groovy program arguments so it will print out the args array b) Pass to JVM the Spring Boot profile i.e. spring.profiles.active=dev Any

Escape correctly double quotes

≯℡__Kan透↙ 提交于 2021-01-28 18:36:52
问题 I have the following two commands executed inside a pipeline def IMAGE = "url/microservices/currency-converter-search:${env.BUILD_NUMBER}" sh "cat task-blueprint.json | jq .containerDefinitions[0].image=${IMAGE} > currency-converter-search-task-${env.BUILD_NUMBER}.json" the problem is that I get back an error because the string that I need to save need to be surrounded by " double quote in order to be save by jq This is the error I get: [workspace] Running shell script + jq

Escape correctly double quotes

南笙酒味 提交于 2021-01-28 18:36:00
问题 I have the following two commands executed inside a pipeline def IMAGE = "url/microservices/currency-converter-search:${env.BUILD_NUMBER}" sh "cat task-blueprint.json | jq .containerDefinitions[0].image=${IMAGE} > currency-converter-search-task-${env.BUILD_NUMBER}.json" the problem is that I get back an error because the string that I need to save need to be surrounded by " double quote in order to be save by jq This is the error I get: [workspace] Running shell script + jq

How to dynamically add all methods of a class into another class

僤鯓⒐⒋嵵緔 提交于 2021-01-28 14:22:51
问题 I have a global shared library on Jenkins implicitly loaded on all pipelines, then my Jenkinsfile is like that: new com.company.Pipeline()() And then the shared library has on directory src/com/company some files, below the Pipeline.groovy class: package com.company import static Utils.* def call() { // some stuff here... } The problem is, this way I have to static declare all methods, thus I lose the context and cannot access jenkins' methods easly without the Pipeline class' instance. As

Surefire fails because of checking if System.exit() was called in one of junit tests

孤人 提交于 2021-01-28 14:16:27
问题 To depict the problem I encountered, let's assume there is a dummy class: import static java.lang.System.exit class Example { void methodGeneratingSystemExit1() { exit 1 } void methodGeneratingSystemExit2() { exit 2 } } And a test against it: import org.junit.Test import org.junit.Rule import org.junit.contrib.java.lang.system.ExpectedSystemExit class ExampleTest { @Rule public final ExpectedSystemExit expectedSystemExit = ExpectedSystemExit.none() @Test void "System exits with code 1 when

How to passing json parameters for test api (restful) in katalon studio?

陌路散爱 提交于 2021-01-28 14:13:00
问题 I created a demo test using reqres.in fake data API. I want to create a user with a name and a job parameter, but the data format required is json. In my Katalon test I tried to do that in the script tab: My parameters are not sent to the API... I didn't find how to do that in Katalon Studio (5.7) and I don't know if it's possible to do that. 回答1: You didn't add parameters to the REST object. Click the + Add button shown in the screenshot and add the following to the parameter table: Name |

How can I replace springloaded jar in Grails installation

点点圈 提交于 2021-01-28 14:09:09
问题 My Grails 2.1.5 app throws exception java.lang.ClassCastException: java.beans.WeakIdentityMap. This seems to be a known problem, and the resolution advised on some forums is to replace springloaded jar version 1.1.1 with 1.1.2 (or to downgrade the java version, which I would rather not do) How can I do that? I tried replacing the jar in Grails installation lib directory, and I got: Error opening zip file or JAR manifest missing : C:/grails-2.1.5/lib/org.springs ource.springloaded/springloaded

Grails 2.5.4: Get all logged in users with HttpSessionListener

主宰稳场 提交于 2021-01-28 13:16:31
问题 I'm trying to get all the current user sessions using the app-info plugin but it doesn't compile in Grails 2.5.4 . Is there another way to get this information? I'm new to Grails. This link has some information including a reference to the app-info plugin but it's old and I wasn't able to get anything to compile. UPDATE I've added this custom class in src\groovy\UserSessions : package usersessions import javax.servlet.http.HttpSessionEvent import javax.servlet.http.HttpSessionListener /

How to access to a static file in resources folder of the shared library from within a class in src directory

落爺英雄遲暮 提交于 2021-01-28 11:59:23
问题 I have the Jenkins shared library with the following structure: resources |-> config.yaml |-> projects.yaml src |_ com |_ rathath |_ jenkins |-> Configuration.groovy In src/com/rathath/jenkins/Configuration.groovy , I want to read YAML files in resources directory. I tried : @Grab('org.yaml:snakeyaml:1.17') import org.yaml.snakeyaml.Yaml import hudson.FilePath // ... def readConfig() { def config = [:] def cwd = hudson.model.Executor.currentExecutor().getCurrentWorkspace().absolutize() new

Sed command ignoring single quotes in Groovy scripts

谁说胖子不能爱 提交于 2021-01-28 08:27:26
问题 Hello I am facing this issue when I try to replace string using SED in Groovy, it's ignoring the Single quotes which I am passing. Here is my code I tried using double quotes inside sed and it's throwing errors. stage('Version') { dir('./Dest/Scripts/') { sh "sed -i 's/VERSION_BUILD=0/VERSION_BUILD= '$Version', System2 = '$name'/g' setversion.sql" } } My desired output is UPDATE &Shared_Version SET SharedVersion = '2010', System1 = 'XXXX', InetsoftVersion = 2, VERSION_BUILD='20180302',