groovy

Groovy split on period and return only first value

岁酱吖の 提交于 2020-01-14 07:21:11
问题 I have the input as var = primarynode.domain.local and now I Need only primarynode from it. I was looking both split and tokenize but not able to do it in one line code. does anyone know how to do it in one line code? 回答1: Well assuming that you want to just get the first word(before . ) from the input string. You can use the tokenize operator of the String If you have def var = "primarynode.domain.local" then you can do def firstValue = ​var.tokenize(".")[0]​ println firstValue output

SonarQube, JaCoCo: (11 of 22 conditions) when they are supposed to be 3 (or 4)

一世执手 提交于 2020-01-14 04:36:30
问题 I am lost on how SonarQube calculates conditions covered by tests. Versions of tools used: * JaCoCo 0.8.1 * SonarQube 7.4 This is my groovy code boolean condition1(boolean b1, boolean b2) { !b1 || !b2 } boolean condition2(boolean b1, boolean b2) { b1 || b2 } boolean condition3(boolean b1, boolean b2) { !b1 && !b2 } boolean condition4(boolean b1, boolean b2) { b1 && b2 } boolean condition5(boolean b1, boolean b2) { b1 && !b2 } boolean condition6(boolean b1, boolean b2, boolean b3) { b1 && b2 &

Transfer Property ids (Array) to other TestCases in SoapUI/Groovy

邮差的信 提交于 2020-01-14 04:16:06
问题 I have an API to get list of ids, name, data etc. (TestCase name GET-APIs_OrderdByID_ASC ) I want to transfer those IDs to other following TestCases in same TestSuite or other TestSuite. In SOAPUI, Property Transfer works within TestSteps in same TestCase. (Using OpenSource version). I need to transfer the property value among different TestCases / TestSuites. Below is the code that I can extract ids from one testCase and also name of testCases/testSteps where I want to transfer. import com

Gradle task syntax: how is it explained from a Groovy perspective?

荒凉一梦 提交于 2020-01-14 01:44:47
问题 I'm having a hard time understanding how Gradle's Groovy DSL works. Unfortunately Gradle is the main use-case for Groovy that I come across in my day to day work, and I've noticed that for many devs, their exposure to Groovy is strictly through Gradle. And that a majority of Gradle users have a very limited grasp of Groovy as a consequence. In my limited understanding of Groovy, the following sintax tokenA tokenB { tokenC } where all tokens are not language keywords, tokenA would be a method

Unable to resolve class com.cloudbees.hudson.plugins.folder.Folder

旧时模样 提交于 2020-01-14 01:39:28
问题 I am trying to gather data from jenkins using groovy script and getting an error: unable to resolve class com.cloudbees.hudson.plugins.folder.Folder Below is the code: import jenkins.model.* import hudson.model.* import groovy.time.TimeCategory use ( TimeCategory ) { // e.g. find jobs not run in last 1 year sometimeago = (new Date() - 1.year) } jobs = Jenkins.instance.getAllItems() lastabort = null jobs.each { j -> if (j instanceof com.cloudbees.hudson.plugins.folder.Folder) { return }

Generic method interception in grails (specifically Controllers)

。_饼干妹妹 提交于 2020-01-14 01:37:06
问题 I'm trying to create a generic function in grails that will allow me to specify a class and function name, and intercept any function calls based on that criteria: getSomeClass().metaClass.invokeMethod = { String methodName, args -> MetaMethod someAction = getSomeClass().metaClass.getMetaMethod(methodName, args) def result = someAction.invoke(delegate, args) if (methodName==getSomeMethodName()) intercept(args, result) return result } This works for POGO, and domain classes, but does not seem

How do i compare user inputed password to credentials passphrase

空扰寡人 提交于 2020-01-13 19:04:59
问题 I have a scripted pipeline that requests the user's password using the input function and compares it with the user's saved credentials passphrase. If the user input is a type string then it works. However, when I changed the input type to password (so it isn't visible on the screen when the user types it), it fails with an assert error. I made sure to enter the password that matches the one in the credentials file. I am using Jenkins 2.83 with latest Credentials Plugin and Credentials

Groovy object properties in map

左心房为你撑大大i 提交于 2020-01-13 16:31:50
问题 Instead of having to declare all the properties in a map from an object like: prop1: object.prop1 Can't you just drop the object in there like below somehow? Or what would be a proper way to achieve this? results: [ object, values: [ test: 'subject' ] ] 回答1: object.properties will give you a class as well You should be able to do: Given your POGO object: class User { String name String email } def object = new User(name:'tim', email:'tim@tim.com') Write a method to inspect the class and pull

Error deploying Grails application - Beginner

纵然是瞬间 提交于 2020-01-13 12:05:14
问题 I am having issues deploying a Grails application. Everything works in the local test environment. ERROR [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean

What is the correct syntax for using HTML builder with mixed content in Groovy 1.7?

被刻印的时光 ゝ 提交于 2020-01-13 10:54:09
问题 On the Groovy example page there is an example of how to use Groovy HTML builder with mixed content: p [ "This is some", b"mixed", "text. For more see the", ahref:'http://groovy.codehaus.org' ["Groovy"], "project" ] This is however not working for me, I get an error message like: expecting ']', found 'mixed' @ line 33, column 23. b"mixed", ^ 1 error The Groovy example page states that: [Note: the syntax in some of these examples is slightly out-dated. See chapter 8 of GINA in the mean-time