jenkins-groovy

How to get user inputs from Jenkins Active Choice parameter using Formatted HTML

╄→гoц情女王★ 提交于 2020-07-10 10:28:08
问题 I defined parameter of type " Active Choices Reactive Reference Parameter " on Freestyle Job it returns HTML text input - <input>. but after populating this data and press "Build" i can't get the user input of this text field, tried with groovy or shell steps, for the parameter name itself i get empty string. it's possible somehow to fetch the value of below field VAPP_ID ? suppose to get "123" This is the groovy script of this Formatted HTML: vappHtml = ''' <ul style="list-style-type: none">

How to pass dynamic values to an environment block during the pipeline execution in Jenkins?

人盡茶涼 提交于 2020-05-17 07:12:05
问题 This is related to one question I asked before: Using groovy to parse JSON object in shell scripts for Jenkin basically I will need to pass a dynamic value as returned from sh scripts to an environment block, so that the following stage can re-use that value and pass the version as a label to JIRA plugin called Xray. But I aware that I cannot pass dynamic values to an environment block during the pipeline execution. So, I think I am going to need try a different route for that, not sure if

Sending email from jenkins pipeline

萝らか妹 提交于 2020-04-18 05:35:49
问题 Hi I am trying to send email notification from jenkins pipeline but it is not sending any email. I am using the below script to send email: pipeline { agent any stages{ stage('Test'){ steps{ echo 'Ok' } } stage('Email'){ steps{ emailext (to: 'abc@xyz.com', replyTo:'abc@xyz.com', subject: "Email report from - '${env.JOB_NAME}'", body: 'test') } } } } The pipeline is being executed but I am not receiving any mail. 来源: https://stackoverflow.com/questions/60996636/sending-email-from-jenkins

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:

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

Jenkins scripted pipeline: Unable to print variables inside shell and set variable values in shell

坚强是说给别人听的谎言 提交于 2020-03-16 07:39:46
问题 Jenkins scripted pipeline. Two issues: I have a global variable var whose value i am trying to access inside shell. But it prints nothing The value of var i am setting in one of the stages using a shell-script, to access in next stage but it prints nothing in shell. What am i missing? (See script below) node { var=10 stage('HelloWorld') { sh ''' echo "Hello World. Var=$var" ===> Prints nothing for var var=20''' } stage('git clone') { echo "Cloning git. Var = $var" ==> Prints 20, and not 10 sh

How to pass Extensible Choice parameter “value” to Jenkins pipeline?

好久不见. 提交于 2020-03-04 05:04:04
问题 I posted How to pass Extensible Choice parameter type to Jenkins pipeline? and found an answer, that is, I least I don't get the core dump anymore. However, I have 2 follow up questions. Again I have 2 jobs, Job1 and Job2. Job1 just triggers Job2. Job2 has an extensible choice parameter called TARGET_VERSION which runs a script that shows Job1's successful build numbers. Here's the Groovy script import hudson.model.* BUILD_JOB_NAME = "Job1" def getBuildJob() { def buildJob = null Hudson

Jenkins Pipeline - Run job on parallel on multiple remote hosts

橙三吉。 提交于 2020-02-25 04:00:09
问题 I have a Jenkins job with string parameter Name = "HOST". I am trying to run one script remotely by connecting to the HOST. It works fine. Similarly, if I enter multiple host names in the HOST parameter, the job has to run on those multiple machines on parallel. How to achieve this? If anybody has any code for this, please do share. Appreciate this help! 回答1: An easy way to run a job on different machines in parallel is to use the declarative Matrix Pipeline example: pipeline { agent none

Required context class hudson.FilePath is missing Perhaps you forgot to surroundsuch ..as: node on Jenkins Pipeline

…衆ロ難τιáo~ 提交于 2020-02-23 07:47:10
问题 Error Message [Pipeline] Start of Pipeline [Pipeline] sh [Pipeline] End of Pipeline org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node My file Android SDK path on my Mac /Users/bhanukaisuru/Library/Android/sdk I also download android sdk tool only. Path is: /Users/bhanukaisuru/Library Environment Variable Config Jenkins > Configure System

Required context class hudson.FilePath is missing Perhaps you forgot to surroundsuch ..as: node on Jenkins Pipeline

泪湿孤枕 提交于 2020-02-23 07:47:09
问题 Error Message [Pipeline] Start of Pipeline [Pipeline] sh [Pipeline] End of Pipeline org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Perhaps you forgot to surround the code with a step that provides this, such as: node My file Android SDK path on my Mac /Users/bhanukaisuru/Library/Android/sdk I also download android sdk tool only. Path is: /Users/bhanukaisuru/Library Environment Variable Config Jenkins > Configure System