groovy

How to define and iterate over map in Jenkinsfile

前提是你 提交于 2020-01-12 05:26:07
问题 My knowledge of groovy doesn't go very far beyond what little I know about Jenkinsfiles. I'm trying to figure out if it's possible to have a map defined in a Jenkinsfile that can then be applied in a "for loop" fashion. I have these variables: mymap = { "k1": "v1" "k2": "v2" "k3": "v3" } I have a stage in my Jenkinsfile that looks like this: stage('Build Image') { withCredentials([[<the credentials>]) { sh "make build KEY={k1,k2,k3} VALUE='{v1,v2,v3}'" } Is there a way to make a Build Image

Groovy execute “cp *” shell command

两盒软妹~` 提交于 2020-01-11 17:41:32
问题 I want to copy text files and only text files from src/ to dst/ groovy:000> "cp src/*.txt dst/".execute().text ===> groovy:000> You can see the command executes w/out error but the file src/test.txt does not get copied to dst/ This also fails: groovy:000> "cp src/* dst/".execute().text ===> groovy:000> However... "cp src/this.txt dst/".execute().text works Also, "cp -R src/ dst".execute().text works Why dose the wild card seem to cause my command to silently fail? 回答1: Wildcard expansion is

Groovy: Generate random string from given character set

我是研究僧i 提交于 2020-01-11 15:48:49
问题 Using Groovy, I'd like to generate a random sequence of characters from a given regular expression. Allowed charaters are: [A-Z0-9] Length of generated sequence: 9 Example: A586FT3HS However, I can't find any code snippet which would help me. If using regular expressions is too complicated, I'll be fine defining the allowed set of characters manually. 回答1: If you don't want to use apache commons, or aren't using Grails, an alternative is: def generator = { String alphabet, int n -> new Random

Getting a source error building Groovy project with Maven

无人久伴 提交于 2020-01-11 11:47:25
问题 I am trying to build my first groovy project with maven but I am getting the following error from maven.. its somettype of source error but Idont understand why I am getting it. [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.186s [INFO] Finished at: Fri Jan 25 15:36:09 EST 2013 [INFO] Final Memory: 15M/163M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal

What happend to groovy++? [closed]

北慕城南 提交于 2020-01-11 09:17:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I just stumbled upon groovy++ and found it quite interesting. Unfortunately it seems that it's not further developed? According to github the last commit was over a year ago. The mailing list is totally inactive and the last message was back in april. There are no recent news about it. Has the project moved and

Why does my Geb test return “failed to create driver from callback” even after updating my Selenium dependency in Grails?

99封情书 提交于 2020-01-11 06:23:31
问题 I am referencing this previous thread (geb.driver.DriverCreationException: failed to create driver from callback) - but am still having problems. I am trying to run Geb functional tests under Grails 2.4.3 and I have my Selenium support dependency set to version 2.42.2. I've also tried it with 2.43.1 and 2.45.0. Geb will stall out and not finish if I try Selenium 2.42.2 or 2.43.1, and it will outright crash if I use 2.45.0. These are the errors I get: If I try Selenium support 2.42.2 or 2.43.1

Way to deep traverse a Groovy object with dot in string using GPath

蹲街弑〆低调 提交于 2020-01-11 06:07:56
问题 The situation I have is that I'm querying MongoDB with a string for a field that is more than one level deep in the object hierarchy. This query must be a string. So for example I'm querying for something like this in Groovy: def queryField = 'a.b.c' //this is variable and can be different every time def result = mongodb.collection.findOne([queryField:5]) The problem no arises that in the result I want to find the value of the nested field. With GPath I could go one level deep and get a's

Way to deep traverse a Groovy object with dot in string using GPath

南楼画角 提交于 2020-01-11 06:07:31
问题 The situation I have is that I'm querying MongoDB with a string for a field that is more than one level deep in the object hierarchy. This query must be a string. So for example I'm querying for something like this in Groovy: def queryField = 'a.b.c' //this is variable and can be different every time def result = mongodb.collection.findOne([queryField:5]) The problem no arises that in the result I want to find the value of the nested field. With GPath I could go one level deep and get a's

Way to deep traverse a Groovy object with dot in string using GPath

旧街凉风 提交于 2020-01-11 06:05:49
问题 The situation I have is that I'm querying MongoDB with a string for a field that is more than one level deep in the object hierarchy. This query must be a string. So for example I'm querying for something like this in Groovy: def queryField = 'a.b.c' //this is variable and can be different every time def result = mongodb.collection.findOne([queryField:5]) The problem no arises that in the result I want to find the value of the nested field. With GPath I could go one level deep and get a's

Way to deep traverse a Groovy object with dot in string using GPath

不羁的心 提交于 2020-01-11 06:05:44
问题 The situation I have is that I'm querying MongoDB with a string for a field that is more than one level deep in the object hierarchy. This query must be a string. So for example I'm querying for something like this in Groovy: def queryField = 'a.b.c' //this is variable and can be different every time def result = mongodb.collection.findOne([queryField:5]) The problem no arises that in the result I want to find the value of the nested field. With GPath I could go one level deep and get a's