Question regarding using groovy code in Jenkins, specifically in Jenkinsfile and groovy plugins
Questions tagged [jenkins-groovy]
2809 questions
0
votes
1 answer
Iterating over groovy file contents
I have two groovy scipts (executed in Jenkins pipeline), one with variables:
// Params file
PARAM1 = "1"
PARAM2 = "2"
PARAM3 = "3"
PARAM4 = "4"
return this
and the second one that loads this file and uses the params:
def load_params() {
def…

badbadllama
- 43
- 6
0
votes
2 answers
Jenkins variable defined inside global variable(env variable)
I have defined an environment(global) variable in jenkins via configuration as
REPORT = "Test, ${CycleNumber},${JOB_NAME}"
I have 1 parameter defined in my pipeline called Cycle which has values new & update. Based on this cycle value CycleNumber…

Bharath Ram
- 37
- 2
- 6
0
votes
0 answers
JENKINS: daysToKeepStr in buildDiscarder is not working
I have a Jenkins script with daysToKeepStr param .
options { buildDiscarder( logRotator(
numToKeepStr:'5',
daysToKeepStr: '7',
) )
daysToKeepStr: discard the builds after 7 days .
But I see in jenkins for every branch one build is…

Deepu Varma
- 11
- 3
0
votes
0 answers
Jenkins Pipeline with build stage
I have a pipeline with four stages namely build, deploy, test, release and i am about to run two concurrent builds and i give manual approval to all by giving input to all stages, Suppose if i am holding my approval in deploy stage (3rd stage) in…
0
votes
1 answer
How do I enable sandbox "Use Groovy Sandbox" option in the Jenkins DSL file?
I have to manually configure the job and tick the "Use Groovy Sandbox" option in order to start reflecting the values for my Active Choice Parameter and Active Choice Reactive Parameters. I want to avoid this manual step and want to enable it from…

Salman Ahsan
- 1
- 1
0
votes
0 answers
Dynamically update values in input parameter boxes in Jenkins pipeline based on user choice
My Jenkins pipeline script has two presets of parameter values.
I want to create a drop-down list on the job page that would fill in default values of these parameters, while allowing users to edit them.
I've tried many variants of calls to…

wl2776
- 4,099
- 4
- 35
- 77
0
votes
0 answers
Jenkins pipeline build succesfully, but the port is not reached using Docker
I am building a pretty basic CI/CD pipeline in Jenkins using Docker to run a toy application in Python. I am using the following groovy script
pipeline {
agent any
environment {
def img =…

Ivan
- 119
- 1
- 8
0
votes
1 answer
Jenkins Dynamic stage creation in declarative pipeline
I need to have a dynamic stages creation. Depending on the list size, it will have X amount of stages. Each of them will have stages before for allocation and preparation. As they have to run parallel, those stages have to be executed on each test…

workingJeff
- 27
- 6
0
votes
0 answers
Get status of the jenkins job from scripted pipeline
I have 3 pre job defined in Jenkins file that i want to run in sequence . Like test1 should execute after test job is completed and test2 should execute after test1 is completed
Currently i read this job in while loop and will trigger in parallel…

Sagar Shah
- 37
- 1
- 1
- 9
0
votes
1 answer
Jenkins parallel and sequential stages
I am trying to run a job with parallel and sequential stages. My code looks like this, each stage will be a groovy script therefore I am running with parallel name: and not parallel {}
stage('Start profiling') {
steps {
script{
parallel…

marcus.w
- 19
- 2
0
votes
1 answer
I can't define dynamic variable in Jenkinsfile pipeline
I want to set dynamic variable in Jenkinsfile and below is my Jenkinsfile
def determineProjectByBranch(branchName) {
String projectName = "";
if (branchName.contains("api")) {
projectName = "api";
} else if (branchName.contains("auth"))…

I have 10 fingers
- 165
- 3
- 20
0
votes
1 answer
List all Jenkins Jobs including subfolders with count and list all enabled and disabled jenkins including subfolders with count using groovy script
In Jenkins, I want to list all Jenkins jobs using the groovy script, I have tried a couple of groovy scripts to get the jobs, and it's working fine, Now I want to get the count of all Jobs without folders and subfolders.
Below is the groovy script…

KNCK
- 103
- 2
- 12
0
votes
1 answer
Setting named parameters in Groovy class does not work, but setting all params does
My goal is to set a param for a class, but leave all other params default (aka set a named param).
For this class: https://javadoc.jenkins-ci.org/jenkins/slaves/RemotingWorkDirSettings.html
You can construct it either just with defaults, or passing…

Rino Bino
- 366
- 3
- 15
0
votes
1 answer
Using the same node / instance on all build jobs in a Jenkins Pipeline
pipeline {
agent { label 'linux' }
stages{
stage("verify1"){
steps {
script {
build(job: "verfiy1", parameters: [string(name: 'verfiy1', value: "${params.verfiy1}")])
}
}
}
…

skkc
- 13
- 4
0
votes
1 answer
ExtendedChoice parameter with Global Variable are not working
I'm in the process of passing a from the Jenkins Global Variable Reference variable called JOB_BASE_NAME to the groovy script. I'm using extendedChoice parameter with Groovy script and it is responsible for listing container images from the ECR on a…

Damith Udayanga
- 726
- 7
- 18