Question regarding using groovy code in Jenkins, specifically in Jenkinsfile and groovy plugins
Questions tagged [jenkins-groovy]
2809 questions
6
votes
1 answer
Jenkins Pipeline stage skip based on groovy variable defined in pipeline
I'm trying to skip a stage based a groovy variable and that variable value will be calculated in another stage.
In the below example, Validate stage is conditionally skipped based Environment variable VALIDATION_REQUIRED which I will pass while…

Haran
- 1,040
- 2
- 13
- 26
6
votes
4 answers
Jenkins pipeline convert all parameters to lowercase
How can I convert all the parameters in a Jenkins pipeline to lowercase. Similar to trim, is there an attribute that one could add as part of the parameter declaration,
For trim, I have something like below,
parameters {
string defaultValue: '',…

Sai
- 1,790
- 5
- 29
- 51
6
votes
1 answer
Closures in Groovy not capturing outside variables
In the context of Jenkins pipelines, I have some Groovy code that's enumerating a list, creating closures, and then using that value in the closure as a key to lookup another value in a map. This appears to be rife with some sort of anomaly or race…

Dustin Oprea
- 9,673
- 13
- 65
- 105
6
votes
0 answers
Is there a way to secure a closure in Jenkins pipeline?
I am currently working on a generic pipeline which is going to be used via shared library to replace existing jobs so that it's easier to manage all jobs from a more centralized place. Most of the existing jobs have these three stages:
allocates a…

tftd
- 16,203
- 11
- 62
- 106
6
votes
1 answer
How to trigger a Jenkins Pipeline on Git commit
I'm setting up Jenkins pipeline for my .Net Core application.
Jenkins multibranch pipeline build gets trigger on Git commit if I am configuring the checkout SCM in multibranch Pipeline configuration. But multibranch Pipeline build is not getting…

Lets_Find
- 61
- 1
- 4
6
votes
2 answers
Jenkins Pipeline waitUntil bash command returns certain string
I have a pipeline stage where I wait to get a certain string back from a sh script, and only when the strings match, continue to next stage, however, it doesn't work as expected:
node('master') {
stage("wait for bash completion") {
…

Moshe
- 4,635
- 6
- 32
- 57
6
votes
2 answers
Get console Logger (or TaskListener) from Pipeline script method
If I have a Pipeline script method in Pipeline script (Jenkinsfile), my Global Pipeline Library's vars/ or in a src/ class, how can obtain the OutputStream for the console log? I want to write directly to the console log.
I know I can echo or…

Craig Ringer
- 307,061
- 76
- 688
- 778
6
votes
4 answers
File not found in Jenkins pipeline script
I'm trying to have a pipeline script currently running on our Jenkins master, execute on a remote Jenkins node. But I'm getting a strange FileNotFound exception.
The most basic version of the pipeline I've been able to reproduce the issue with is…

vruum
- 455
- 1
- 5
- 14
6
votes
2 answers
Jenkins Pipeline 'Wrap' Stages for Xvfb start
I'm trying to wrap stages by using:
wrap([$class: 'Xvfb', additionalOptions: '', assignedLabels: '', autoDisplayName: true, debug: true, displayNameOffset: 100, installationName: 'XVFB', parallelBuild: true]) {
If I have Jenkins file with…

Nael Marwan
- 1,030
- 1
- 13
- 32
6
votes
1 answer
Error java.lang.NoSuchMethodError: No such DSL method '***' found among steps
I'm a beginner with Jenkins and Groovy. I'm working on a pipeline library.
One file (version.groovy) is defined as follow:
def dateInternal = { new Date().format('yy.Mdd.Hmm') }.memoize()
def date() {
dateInternal()
}
In another file I call…

schglurps
- 1,387
- 1
- 14
- 26
6
votes
1 answer
Getting unknown type : import in groovy in Jenkins Pipeline
I am trying to create a Jenkins Pipeline Script using groovy. However, the import statement is giving me a compilation error - Unknown Type : Import. Not sure why.

Bipin
- 63
- 1
- 3
6
votes
1 answer
Read json from jenkins
Im trying to read a json file from within a jenkinsfile with grovvy script. Im using the pipeline-utility-steps-plugin, which allows to read the json file as string with the following.
def projects = readJSON file:…

Rene Sørensen
- 99
- 1
- 1
- 8
6
votes
4 answers
Propagating logs in shared library to jenkins job console
I am trying to write a shared libray which combines of global variables and shared functions to perform automated task of build and deployment for our project
The project layout as below:
The project has two major parts:
Global shared variables…

Joey Trang
- 1,105
- 2
- 23
- 44
6
votes
3 answers
Load properties from properties file and make them available throughout the job/pipeline - Jenkins declarative syntax
My requirement is simple, i just want to externalize some 'values' to make my Jenkinsfile more re usable and for this i need to load the properties from a file which is going to be right next to Jenkinsfile, and make sure that these properties are…

ishan
- 1,202
- 5
- 24
- 44
5
votes
1 answer
Deploy Helm charts into Kubernetes with Jenkins job
I want to create a Jenkins job which deploys Helm chart into Kubernetes cluster.
Helm charts are stored into Bitbucket repository.
pipeline {
agent any
stages {
stage('Download Helm Charts') {
steps {
…

Peter Penzov
- 1,126
- 134
- 430
- 808