groovyshell

Using GroovyShell as “expression evaluator/engine” (or: How to reuse GroovyShell)

≯℡__Kan透↙ 提交于 2021-01-27 02:55:26
问题 I'm using GroovyShell as an "expression evaluator/engine" inside my program. It accepts two inputs: (a) one or more init scripts (b) user-defined script. Both are then concatenated at runtime as big chunk of script (text) and feed to the shell. String initScripts = getFromDB() String userScript = getFromUser() def shell = new GroovyShell() output = shell.evaluate(initScripts + userScript) The above code will run in a loop, where the contents of userScript will vary. So far, initScripts only

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

怎甘沉沦 提交于 2021-01-07 06:38:15
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

有些话、适合烂在心里 提交于 2021-01-07 06:37:33
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

The same shell command behaves differently if it is located in different stages of Jenkins pipeline

浪子不回头ぞ 提交于 2021-01-07 06:37:14
问题 I'm trying to execute following stage in Jenkins pipeline stage('RUN') { steps{ dir("airflow-dags") { sh "find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0" } } } If this stage is located in the last position (after deploy and other stuff) it returns nothing: 08:56:58 Running in /home/jenkins/workspace/QA_deploy_Docker/airflow-dags [Pipeline] { [Pipeline] sh 08:56:59 + find ./volumes/dags/ -maxdepth 1 -name '*.py' -print0 [Pipeline] } [Pipeline] // dir [Pipeline] } [Pipeline] // stage If

Lock contention in Groovy Shell interpreter under high load

大憨熊 提交于 2021-01-05 09:36:24
问题 We are evaluating GroovyShell interpreter (v2.4) in our application for dynamically executing standard Java syntax. Earlier, we were using Java BeanShell Interpreter for it, but it has an issue under high load which prompted us to look for an alternative such as Groovy. Sample Java Code static String script = "int y = x * x; System.out.println(\"** value of y ** :: \" + y ); "; GroovyShell gs = new GroovyShell(); Script evalScript = gs.parse("void evalMethod() {" + script + "}"); // bind

Lock contention in Groovy Shell interpreter under high load

隐身守侯 提交于 2021-01-05 09:33:52
问题 We are evaluating GroovyShell interpreter (v2.4) in our application for dynamically executing standard Java syntax. Earlier, we were using Java BeanShell Interpreter for it, but it has an issue under high load which prompted us to look for an alternative such as Groovy. Sample Java Code static String script = "int y = x * x; System.out.println(\"** value of y ** :: \" + y ); "; GroovyShell gs = new GroovyShell(); Script evalScript = gs.parse("void evalMethod() {" + script + "}"); // bind

GroovyShell().parse passing parameters

前提是你 提交于 2020-06-28 03:00:26
问题 I have a groovy script that needs to parse a class from an external groovy script. I am not sure how to pass parameters. Here is what works: Groovy script I am running is using this line to parse the external class from external.groovy: new GroovyShell().parse(new File('External.groovy')) Here is what external.groovy looks like: class External { public external() { println "Hello" } } It works. The problem I am having, I cant find a way to pass parameters to the external method. Here is what

How to get a value of a dynamic key in Groovy JSONSlurper?

只愿长相守 提交于 2020-03-04 18:03:13
问题 The variable resp contains below JSON response - {"name":"sample","address":{"country":"IN","state":"TN","city":"Chennai"}} I have planned using param1 variable to get the required key from JSON response, but I'm unable to get my expected results. I'm passing the param1 field like - address.state def actValToGet(param1){ JsonSlurper slurper = new JsonSlurper(); def values = slurper.parseText(resp) return values.param1 //values.address.state } I'm getting NULL value here -> values.param1 Can

How catch curl response into variable in Jenkinsfile

↘锁芯ラ 提交于 2020-01-23 05:55:34
问题 I want to curl an URL and capture the response into a variable. when I curl a command and echo its output I get the correct response as below sh 'output=`curl https://some-host/some-service/getApi?apikey=someKey`;echo $output;' I want to catch the same response into a variable and use that response for further operation Below is my Jenkinsfile pipeline { agent { label "build_2" } stages { stage('Build') { steps { checkout scm sh 'npm install' } } stage('Build-Image') { steps { echo '.........