groovy

Read Config file in jenkins groovy script for build parameters

随声附和 提交于 2020-01-24 20:00:08
问题 I have a choice list for a parameter. The values in choice list is based on user who logs in jenkins. For example a student opts for subjects maths science and commerce, he should be able to see his own subjects in the choice drop down. I have the mapping of each student with their enrolled subject in a json file. I used Config File Provider plugin to refer this file in jenkins. Now how should I load this configuration files through groovy script in the choice parameters. I am using Extended

passing a closure in a plugin extension in gradle

孤者浪人 提交于 2020-01-24 13:23:23
问题 I'd like to pass a closure as configuration for a plugin. Here is a minimal version of it: package org.samuel.gradle.plugins import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task class TestPlugin implements Plugin<Project> { void apply(Project project) { project.extensions.create("testConfig", TestConfig) Task test = project.task("testTask") { doFirst { println "The message is already " + project.extensions.testConfig.message println "Trying to run closure " +

passing a closure in a plugin extension in gradle

泪湿孤枕 提交于 2020-01-24 13:22:14
问题 I'd like to pass a closure as configuration for a plugin. Here is a minimal version of it: package org.samuel.gradle.plugins import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task class TestPlugin implements Plugin<Project> { void apply(Project project) { project.extensions.create("testConfig", TestConfig) Task test = project.task("testTask") { doFirst { println "The message is already " + project.extensions.testConfig.message println "Trying to run closure " +

Jenkins groovy - How to retrieve tag from latest commit?

半城伤御伤魂 提交于 2020-01-24 13:15:31
问题 To fetch the latest commit from branchName , we run below code: treeMapData = git(branch: branchName, credentialsId: credential, url: "${gitLabServer}/${projectName}/${repo}.git") It is ensured that there is one tag per commit, as per our workflow We want to build the code, only if the commit is tagged. How to retrieve the tag name for that latest commit? 回答1: We can fetch the tags from the repo in case Jenkins hasn't already. git fetch --tags We need to find a tag(s) which point to a

Groovy split using file.seperator

我们两清 提交于 2020-01-24 12:59:06
问题 I'm getting an error as follows Groovy script throws an exception of type class java.util.regex.PatternSyntaxException with message = Unexpected internal error near index 1 \ ^ from the Split statement as follows: String strClassPath = System.getProperty("java.class.path"); String[] path = strClassPath.split(System.getProperty("file.separator")); How should I make this work correctly for both UNIX and Windows systems (that's why I'm using "file.separator") Many thanks in advance 回答1: This

How to exclude local maven repository when installing grape dependencies

不问归期 提交于 2020-01-24 12:55:08
问题 I want install some grape depencies to my project: grape install org.codehaus.groovy.modules.http-builder http-builder 0.6 How I can exclude downloading from my maven local repository ? Becase by default it looks like it download from my local repo found org.codehaus.groovy.modules.http-builder#http-builder;0.6 in localm2 found org.apache.httpcomponents#httpclient;4.2.1 in localm2 found org.apache.httpcomponents#httpcore;4.2.1 in localm2 found commons-logging#commons-logging;1.1.1 in localm2

RESTEasy, CDI, embedded Jetty, bean validation is ignored

喜你入骨 提交于 2020-01-24 01:04:07
问题 I've a Groovy project where I use RESTEasy with Weld and deploy to embedded Jetty. What I can't seem to get working is bean validation. RESTEasy documentation says that adding resteasy-validator-provider-11 along with hibernate validator dependencies ( hibernate-validator, hibernate-validator-cdi, javax.el-api, javax.el ) is enough. But the bean validation is simply ignored by RESTEasy. I curiously also get the following message in the logs: plugins.validation.ValidatorContextResolver -

soapUI - embbed XML in a request using groovy

前提是你 提交于 2020-01-23 17:02:33
问题 I'm making test cases on soapUI, on some steps I would use a REST quest and put XML code in the lower pane, something like <dataList> <data> 3.1416 </data> <data> 5.11 </data> </dataList> But I need to get the response and store the results that will be contained inside the XML text of the response, to verify that the web service is executing proper operations and then send more requests using the received results. Thanks everyone! 回答1: I could solve this using properties and Property

Java jars unable to resolve class

巧了我就是萌 提交于 2020-01-23 12:01:20
问题 I'm relatively new to Java development...I thought I understood how class path works, but I must be missing something. Using Groovy, I have 2 external classes referenced by imports. When I execute the script, I get "unable to resolve class" errors. I have the jars for these in the same directory as the script. If I un-jar them, the script works, but jar'd up the script does not. What am I missing here? EXAMPLE import org.apache.log4j.Logger Logger log = Logger.getLogger("ldap_delete") log

How to render a List with Groovy's MarkupBuilder

三世轮回 提交于 2020-01-23 10:47:07
问题 I am converting a Map to XML using the Groovy MarkupBuilder. This Map can contain simple key/value pairs, other Maps, or Lists of Maps. I am piggybacking from the code here. import groovy.xml.MarkupBuilder def map = [ key1:'value1', key2:'value2', nestedMap : [ key1:'bar1', key2:'bar2' ], select : [ [option:'foo1'], [option:'foo2'] ] ] Closure renderMap( Map map ){ return { for ( entry in map ){ switch( entry.value.getClass() ){ case Map : "${entry.key}" renderMap( entry.value ) break case