groovy

How to disable error highlighting in VS Code?

喜夏-厌秋 提交于 2021-01-26 21:53:46
问题 I need to disable error highlighting in Java files in VS Code. VS Code tries to check a Groovy file while thinking it is a Java file. As you can see in the picture all imports after the first and the types after the first field are highlighted red (due to missing semicolons). However I do not want the error check for this Groovy file. NOTE: I only have the plugins Clang, RedHat.Java, Markdown PDF, Sort Lines, and Uncrustify installed. Even if I disable all the red highlighting is visible. 回答1

Jenkins pipeline - No such DSL method 'build'

偶尔善良 提交于 2021-01-25 06:54:22
问题 I am using below Groovy Script in Jenkins Pipeline to call a Free style job but it ends up with "No such DSL method 'build'" error. node{ def branches = [:] List rows =["Test2", "Test1"] for (int i = 0; i <rows.size(); i++) { def index = i String db = rows[i] branches["branch${i}"] = { build job: 'CopyFile', parameters: [[$class: 'StringParameterValue', name: 'DatabaseName', value: db], [$class: 'StringParameterValue', name:'dummy', value: "${index}"]] } } parallel branches } 回答1: Installing

Jenkins pipeline - No such DSL method 'build'

好久不见. 提交于 2021-01-25 06:52:13
问题 I am using below Groovy Script in Jenkins Pipeline to call a Free style job but it ends up with "No such DSL method 'build'" error. node{ def branches = [:] List rows =["Test2", "Test1"] for (int i = 0; i <rows.size(); i++) { def index = i String db = rows[i] branches["branch${i}"] = { build job: 'CopyFile', parameters: [[$class: 'StringParameterValue', name: 'DatabaseName', value: db], [$class: 'StringParameterValue', name:'dummy', value: "${index}"]] } } parallel branches } 回答1: Installing

Exclude null values using JSONBuilder in Groovy

一笑奈何 提交于 2021-01-22 13:56:39
问题 Is it possible to create JSON values in Groovy using the default JsonBuilder library to exclude all the null values of an object? Such as what Jackson does in Java by annotating classes to exclude null values. An example would be: { "userId": "25", "givenName": "John", "familyName": null, "created": 1360080426303 } Which should be printed as: { "userId": "25", "givenName": "John", "created": 1360080426303 } 回答1: Not sure if it's OK for you as my method works on a Map with List properties: def

How get full path to file build.gradle by Groovy?

瘦欲@ 提交于 2021-01-22 04:28:22
问题 I need create file in my java-project near buiid.gradle-file. I must create task (Groovy task) in build.gradle-file, my task must create file near buiid.gradle in my project, but I do not know - how do get path to buiid.gradle-file, that is putting in my project. How get full path to file buiid.gradle by Groovy? Help me, please. 回答1: There are several ways to accomplish this. If you look at the Working With Files page, you can simply use the file() method that is a part of the Project object.

How to run Jenkins Groovy scripts directly from Intellij or Eclipse

眉间皱痕 提交于 2021-01-21 09:36:22
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. alex is looking for a canonical answer : The question's author is correct: trying to use Jenkins as a Groovy IDE is a living nightmare. I will award the bounty to anyone who describes how to set up a local IntelliJ (or whatever) environment for executing Groovy scripts that you'd ordinarily execute with Jenkins. It's not obvious because many scripts may contain Jenkins-specific methods that rely

How to run Jenkins Groovy scripts directly from Intellij or Eclipse

守給你的承諾、 提交于 2021-01-21 09:35:13
问题 The bounty expires in 6 days . Answers to this question are eligible for a +50 reputation bounty. alex is looking for a canonical answer : The question's author is correct: trying to use Jenkins as a Groovy IDE is a living nightmare. I will award the bounty to anyone who describes how to set up a local IntelliJ (or whatever) environment for executing Groovy scripts that you'd ordinarily execute with Jenkins. It's not obvious because many scripts may contain Jenkins-specific methods that rely

Jenkins: get environment variables in the body of a global function

て烟熏妆下的殇ゞ 提交于 2021-01-21 05:33:46
问题 I have a shared global function on PublishGitHub.groovy looks like this: #!/usr/bin/env groovy def call(body) { def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config echo "\u001B[32mINFO: Publishing...\u001B[m" body() echo "\u001B[32mINFO: End Publish...\u001B[m" } And a code on my JenkinsFile: environment { VERSION = "v1.3.${env.BUILD_NUMBER}" } stages { stage ('Publish WebAPI'){ steps{ echo "\u001B[32mINFO: Start Publish...\u001B[m" PublishGitHub{ echo "This

Jenkins: get environment variables in the body of a global function

落花浮王杯 提交于 2021-01-21 05:33:24
问题 I have a shared global function on PublishGitHub.groovy looks like this: #!/usr/bin/env groovy def call(body) { def config = [:] body.resolveStrategy = Closure.DELEGATE_FIRST body.delegate = config echo "\u001B[32mINFO: Publishing...\u001B[m" body() echo "\u001B[32mINFO: End Publish...\u001B[m" } And a code on my JenkinsFile: environment { VERSION = "v1.3.${env.BUILD_NUMBER}" } stages { stage ('Publish WebAPI'){ steps{ echo "\u001B[32mINFO: Start Publish...\u001B[m" PublishGitHub{ echo "This

极简化ES数据同步,终于从繁琐重复的代码里脱身了

社会主义新天地 提交于 2021-01-20 21:02:51
一、背景 Elasticsearch是最近几年非常热门的分布式搜索和数据分析引擎,携程内部不仅使用ES实现了大规模的日志平台,也广泛使用ES实现了各个业务场景的搜索、推荐等功能。 本文聚焦在业务搜索的场景分享了我们在做数据同步方面的思考和实践,希望能对大家有所启发。 二、现状调研 数据同步是个很麻烦的事情,在各种论坛、分享中被大家反复讨论。 我们的需求大致包括全量、增量地从Hive、MySQL、Soa服务、Mq等不同类型的数据源获取数据,部分数据还需要进行一定的计算或者转换,然后近实时地同步到ES中,以被用户搜索到。 为了讨论方便,假定本文的场景是文章搜索的场景: 索引内容为文章,主要的信息保存在article表里; 每个文章关联了tag,保存在article_tag表里; tag表里的tagName也需要进入ES索引,以便使用标签名字搜索文章。 在以前同步这样的数据进入ES,单条文章的数据组装伪代码如下: List<Long> tagIds = articleTagDao.query("select tagId from article_tags where articleId=?", articleId); List<TagPojo> tags =tagDao.query("select id, name from tags whereid in (?)");