groovy

How to add timestamp for artifacts in Jenkins

送分小仙女□ 提交于 2021-02-04 16:40:22
问题 I have following Jenkisfile and I'm trying to upload the artifacts with a timestamp. import groovy.transform.Field @Field def timeStamp = Calendar.getInstance().getTime().format('YYYYMMdd-hhmmss',TimeZone.getTimeZone('CST')) node { stage('Creating some artifacts') { sh 'touch hello.txt hi.txt' } stage('Uploading artifacts') { def server = Artifactory.server ('art-1') def uploadSpec = """{ "files": [ { "pattern": "*.txt", "target": "repo1/Dev/${env.BUILD_NUMBER}/*.txt.${timeStamp}" } ] }"""

transpose a map collecting keys along the way

走远了吗. 提交于 2021-02-04 15:09:29
问题 I'm trying to transpose a map so that: [x: y, w: y, a: b] becomes [y: [x, w], b: a] (all variables are strings) Doing something like ["x": "y", "w": "y", "a": "b"].collectEntries { [it.value, it.key] } gets me part way, but stomps on the first new value for "y". I only get: [y:w, b:a] What is the best way to slurp up the new values into an array for their common new key? Thanks for any help or suggestions. 回答1: I hope this helps : def map = ["x": "y", "w": "y", "a": "b"] map.groupBy{ it.value

transpose a map collecting keys along the way

两盒软妹~` 提交于 2021-02-04 15:08:44
问题 I'm trying to transpose a map so that: [x: y, w: y, a: b] becomes [y: [x, w], b: a] (all variables are strings) Doing something like ["x": "y", "w": "y", "a": "b"].collectEntries { [it.value, it.key] } gets me part way, but stomps on the first new value for "y". I only get: [y:w, b:a] What is the best way to slurp up the new values into an array for their common new key? Thanks for any help or suggestions. 回答1: I hope this helps : def map = ["x": "y", "w": "y", "a": "b"] map.groupBy{ it.value

Spring源码搭建

余生长醉 提交于 2021-02-02 16:32:34
第一步:下载Spring源码 从github上下载Spring源码。我们可以下载release版本,也可以 git clone 相应的版本。这里下载的是当前最新版本: spring-framework-5.2.1.RELEASE 第二步:配置与源码相匹配的环境 Spring 5版本是用Gradle进行构建的,因此我们进入到 gradle/wrapper 目录,打开 gradle-wrapper.properties 文件,我们可以看到如下信息: distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists 配置属性信息描述: distributionUrl :要下载的gradle的地址,使用哪个版本的gradle通过这里来指定 distributionBase 和 distributionPath :两个属性组合在一起,指定 distributionUrl 属性下载下来的文件的解压后的存放位置。 distributionPath 是

Postman+Newman+Git+Jenkins实现接口自动化测试持续集成

这一生的挚爱 提交于 2021-02-01 08:02:55
接口测试脚本一般的执行流程 做接口测试的话,首先要考虑的是如何选择一个合适的工具? 在忽略工具是否好用,是否能满足业务要求的前提下,需要考虑以下2点: 1、要考虑工具的学习成本 2、要考虑团队的协作  接口测试脚本的执行流程: 团队成员协作编写接口用例->用例归档到git/svn->脚本集成jenkins,在环境更新后自动触发执行或定时执行。 Postman工具常见的接口测试流程是怎样的? 使用Postman+Newman+Git+Jenkins+钉钉 /邮件提醒 Windows系统Newman安装 1、下载Node.js进行安装,然后配置node的环境变量 2、借助npm工具,安装Newman npm install -g newman 3、运行Newman 通过Newman来运行某个postman脚本: newman run mycollection.json 用newman执行postman脚本的效果如下: Centos系统Newman安装 1、先下载安装nodejs ( 必须安装10.0以上的版本 ) 从http://nodejs.cn/download/下载linux系统压缩包 ,,解压,配置环境变量 tar xvJf ***.tar.xz echo "export PATH=\"\$PATH:/root/tools/node-v14.8.0-linux-x64/bin\

is there a way to specify a constructor for a groovy script?

余生长醉 提交于 2021-01-29 22:21:24
问题 I have a groovy script called Foo.groovy , an instance of that script can be constructed using the following syntax: def foo = new Foo() i know if Foo.groovy looks like: import groovy.transform.Field @Field def bar def someMethod() { //... } the following syntax: def foo = new Foo(bar: 'baz') will use some default constructor and actually set the bar field to baz , but let's say that i wanted to manipulate the passed value of bar to add an exclamation point at the end like so "${bar}!" would

Jenkins does not show variables output in ECHO request in the groovy-pipeline

吃可爱长大的小学妹 提交于 2021-01-29 17:46:05
问题 just for example. I have this part of code in groovy-pipeline: echo "${GIT_BRANCH}" if ("${GIT_BRANCH}" == 'origin/mysuperbranch') { echo 'Branch name is "${GIT_BRANCH}". We can continue' } else { echo 'Branch name is "${GIT_BRANCH}". We can not continue' isValid = false return true } And let's look on output: [Pipeline] echo origin/mysuperbranch [Pipeline] echo Branch name is "${GIT_BRANCH}". We can continue Why in first output i can see what is in the variable ${GIT_BRANCH} , but in the

How do I create a column name in DBF more than 10 characters in javadbf library?

强颜欢笑 提交于 2021-01-29 14:11:51
问题 I am using javadbf from github (link: https://github.com/albfernandez/javadbf) to create DBF files, but I cannot create a column with a name greater than 10 characters: fields[39].setName("WAY_SONIC_ROKETS"); I tried to change this in the project from the github, but nothing came of it. A request from knowledgeable people to give an answer whether this can be changed or, if possible, suggest a place where it needs to be corrected. If understood correctly, this is only generated in DBFField.

sudo inside Jenkins pipeline script

时光总嘲笑我的痴心妄想 提交于 2021-01-29 10:52:54
问题 We have the following setup: We have few UNIX boxes. There are users provisioned to these boxes (ex: spande ). These users have limited privileges, but can do sudo to elevate the permissions (sudo user: admin ). The sudo happens without any password. We have a CICD tool in Jenkins which uses these Unix boxes as slave. We have spande credentials to login into this unix servers via Jenkins. We are using Jenkins Pipeline Scripts (groovy). All is well, but we want the Jenkins script to run with a

String interpolation in a multi-line Groovy string

喜你入骨 提交于 2021-01-29 10:31:01
问题 I have a multi-line string in which I dynamically populate an SQL query from a map. I am getting a MissingPropertyException that is a result of the query not recognising the map key or values. Is there a way around this? def multiString = """ def person = ['John': 'Builder'] person.each{ key, value -> String query = """ UPDATE person SET value = '${value}' WHERE name = '${key}' """ } """ 回答1: I figured it out. I needed to escape the $ using a backslash. def multiString = """ def person = [