jenkins-pipeline

Jenkins pipeline java.io.NotSerializableException java.util.regex.Matcher error even with @NonCPS

a 夏天 提交于 2020-04-07 14:34:03
问题 I am using @NonCPS in front of my Jenkinsfile function which performs a regex match and i'm still getting java.io.NotSerializableException java.util.regex.Matcher error even with the @NonCPS annotation. Note, it calls the function many times and the exception only occurs once a match is actually made. Here is my code: @NonCPS def extractEndTime(logLine) { def MY_REGEX = /.*(20[0-9]{2}-[0-9]{2}-[0-9]{2}).([0-9]{2}:[0-9]{2}:[0-9]{2}).*\"\w+\"\sthe text\s(\w+)\./ m = (logLine =~ TEST_LOGLINE_END

Jenkins pipeline java.io.NotSerializableException java.util.regex.Matcher error even with @NonCPS

混江龙づ霸主 提交于 2020-04-07 14:32:08
问题 I am using @NonCPS in front of my Jenkinsfile function which performs a regex match and i'm still getting java.io.NotSerializableException java.util.regex.Matcher error even with the @NonCPS annotation. Note, it calls the function many times and the exception only occurs once a match is actually made. Here is my code: @NonCPS def extractEndTime(logLine) { def MY_REGEX = /.*(20[0-9]{2}-[0-9]{2}-[0-9]{2}).([0-9]{2}:[0-9]{2}:[0-9]{2}).*\"\w+\"\sthe text\s(\w+)\./ m = (logLine =~ TEST_LOGLINE_END

How can I do string to integer conversion in a Jenkinsfile?

怎甘沉沦 提交于 2020-04-06 07:23:16
问题 I have the following in my Jenkinsfile: pipeline { agent none environment { timeout_mins = 1 } options { timeout(time: "${env.timeout_mins}", unit: 'MINUTES') } stages { stage("test print") { steps { echo "timeout_mins: ${env.timeout_mins}" sh "sleep 120" } } } } I'd like to re-use environment params such as timeout_mins in multiple places, but need to convert it to integer in certain places for certain plugins. The error I get with the above example is as follows: Processing environment for

How can I do string to integer conversion in a Jenkinsfile?

℡╲_俬逩灬. 提交于 2020-04-06 07:23:05
问题 I have the following in my Jenkinsfile: pipeline { agent none environment { timeout_mins = 1 } options { timeout(time: "${env.timeout_mins}", unit: 'MINUTES') } stages { stage("test print") { steps { echo "timeout_mins: ${env.timeout_mins}" sh "sleep 120" } } } } I'd like to re-use environment params such as timeout_mins in multiple places, but need to convert it to integer in certain places for certain plugins. The error I get with the above example is as follows: Processing environment for

How to loop parametrized parallel stages in Jenkins declarative pipeline?

大城市里の小女人 提交于 2020-03-26 04:06:25
问题 How to loop parametrized parallel stages in Jenkins declarative pipeline? (Or scripted pipeline, if declarative is not able to) Here is my simple pseudo example. How to loop ('deploy serverN') stages? Array may have 1..n variables. I would not like to duplicate code. There must be a way in Jenkins pipelines?? Or should I use matrix. I have tried a few, but not succesfully. @Library('adm-jenkins-lib@trunk') def SERVERS = ['server1.com','server2.com',...] deployPipeline([servers: SERVERS,

Is there a way I could report back my robot tests results from Jenkins to slack?

[亡魂溺海] 提交于 2020-03-25 19:22:06
问题 I have tests that run on Jenkins. - Robot Framework Tests. They run on a scheduled basis, but no one really takes a look. I wanted to see if there is a mechanism using which, I could report back the results to a slack channel once the job completes executing tests. def branch = "branchName" node ('AWS-LoadTest') { stage ('Checkout') { cleanWs() checkout([$class: 'GitSCM', branches: [[name: branch]], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs:

escaping special character in groovy

前提是你 提交于 2020-03-25 13:51:33
问题 I want to run my command in background.And I am trying this in jenkins pipeline This is my command sh "./node_modules/.bin/selenium-standalone start \&" But when I run this command & gets single quote because of which the command fails. OUTPUT : ./node_modules/.bin/selenium-standalone start '&' Can anyone suggest how I should escape the & in groovy so I just get & without single quote. 回答1: This won't work that easily, first because & is a command for job control in the interactive shell, and

escaping special character in groovy

感情迁移 提交于 2020-03-25 13:50:08
问题 I want to run my command in background.And I am trying this in jenkins pipeline This is my command sh "./node_modules/.bin/selenium-standalone start \&" But when I run this command & gets single quote because of which the command fails. OUTPUT : ./node_modules/.bin/selenium-standalone start '&' Can anyone suggest how I should escape the & in groovy so I just get & without single quote. 回答1: This won't work that easily, first because & is a command for job control in the interactive shell, and

Catching an exception when loading a groovy file

荒凉一梦 提交于 2020-03-23 04:06:52
问题 I have these 3 groovy files: A.groovy: // ... stage("Test") { throw new Exception("This script fails") } B.groovy: // ... stage("Test") { // Nothing, want this to pass } main.groovy: // ... m = [:] status = [:] scripts = ["A", "B"] for script in scripts { m["${script}"] = { stage("${script}") { try { load "${script}.groovy" status["${script}"] = true } catch (Exception e) { status["${script}"] = false } } } } parallel m for result_iterator in status: print "${result_iterator.key} resulted in

Installed 'github-autostatus' plugin not updating Job & stage monitoring status in GitHub

£可爱£侵袭症+ 提交于 2020-03-21 07:00:32
问题 Installed https://plugins.jenkins.io/github-autostatus/ plugin Watches pipeline jobs and provides job and stage stats such as time and pass/fail. Can be configured to update GitHub commit status (one status per stage) and send stats to an InfluxDB instance, or StatsD collector, for build health monitoring of job/stage timing and success rate. As highlighted in link, I am expecting this to appear in stage before PR merge to target button gets enabled. But post plugin installation & restart it