Questions tagged [jenkins-groovy]

Question regarding using groovy code in Jenkins, specifically in Jenkinsfile and groovy plugins

2809 questions
0
votes
0 answers

Jenkins use return value from function as variable

I am working on a global library for my Jenkins installation. My function should read from an external vault and return a secret which will be used inside the body of the function. Basically, I am trying to replicate the flow of the…
MARCO LAGALLA
  • 227
  • 5
  • 12
0
votes
1 answer

Groovy to list Jenkins jobs in a defined subfolder but not levels below given folder

I need to get a list of jobs from a given folder in Jenkins. I do not want the jobs in subfolders that I do not specify. If I have a folder structure with jobs "some_folder/some_subfolder/another_subfolder", the example will return all jobs in…
herkimer
  • 1
  • 3
0
votes
0 answers

jenkins refresh node labels cache

I have a pipeline where it runs on node which has label 'build'. In this pipeline if it fails any stage on one node it retries all the stages again in same pipeline on different nodes.. what I do in the pipeline is when a stage is failed I add label…
0
votes
0 answers

How to add parameters to jenkinsfile based on condition

I have a requirement as below i will configure 2 different jobs with different parameters. i am using pipeline shared libraries and under vars folder, my deriveJobParams.groovy looks as follows. def call(Map config = [:]) { properties([ …
0
votes
1 answer

How To Pass a Groovy Array to Shell Script in Jenkins

I need to get the array that I have in my groovy Script and pass it shell Script for further Calculation in the Shell Script I have tried multiple was but I am not getting the array passed to Shell Script. templates =…
0
votes
0 answers

Jenkins Add permissions to folder using groovy

I need to add some permissions (Read, Build, View, cancel etc) to multiple users at the same time. def users = [user1, user2] for(user in users){ String userID = user; jobDsl scriptText: """ folder('example') { …
Parkjin
  • 11
  • 4
0
votes
1 answer

Jenkins issue while adding jira site using OAuth

error seen while trying to test connection I am getting an error "Invalid input length 849" when I tried to test the connection with the Jira site in Jenkins. I tried to add the site in the Jenkins->configure system section using OAuth.But I can…
0
votes
0 answers

In Jenkins display the directories from gitlab repo in build with parameters as a drop down

agent { label 'jenkins-slave' } environment { CRED_REPO_URL = 'gitcredentials.git' SERVICES_REPO_URL = 'gitrepo' ENV_NAME = 'dev_dev' REGION = 'ap-south-1' } parameters { choice name: 'ENV',…
Tom
  • 1
  • 1
0
votes
1 answer

What is the order of execution of jobs in a Jenkins pipeline?

I have a pipeline with multiple jobs inside it, but I'm facing a dilemma. What is the order of execution of the jobs inside the pipeline? Is it the order from the script? The reason I'm interested is because I want JOB1 to run at the beginning of…
0
votes
1 answer

Cronjob every day except the last 5 days of the month

Currently, I run a job via cronjob, which starts every day at 4AM. Now the exception has been added that it should not run the last 5 days of the month. What would the cron syntax look like if the exception was included? currently: 0 0 4 * * *
Scamus
  • 21
  • 5
0
votes
0 answers

I want my RPM SIGNing job to be resilient so that I can still run my pipelines when one site/node is down

I have an RPMSIGN job thats configured to run in 2 continents, Europe and North America. The Europe site is the master and N.A. is the failover incase EU is down. The problem is that when EU becomes unavailable, it doesnt failover to US. How can I…
ugobozz
  • 9
  • 1
0
votes
1 answer

How to list a windows share folder by active choices parameter or extened choice parameter in jenkins

I tryed to write a groovy script with extened choice parameter: import jcifs.smb.* try { def source = "smb://192.168.1.xx/build/" NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("mydc", "jenkins", "*****"); def dir = new…
halong
  • 70
  • 6
0
votes
2 answers

How do we set x-www-form-urlencoded type body in jenkins pipeline/groovy post request?

def body ='{"1":"ab","2":"cd"}' def response = httpRequest(httpMode: 'POST', url: "https://***/xyz", customHeaders:[[name:"Content-type",value:"application/x-wwww-form-urlencoded"]], body =body) Expected response is json values.Here always received…
0
votes
1 answer

Getting java.lang.IllegalArgumentException: One or more variables have some issues with their values in jenkins pipeline

I have a Jenkins declarative pipeline wherein I am trying to store the value returned from a method into environment variable as shown below. steps { script { def job =…
svw1105
  • 127
  • 1
  • 15
0
votes
1 answer

How to read contents from properties file from Jenkins pipeline

I have a Jenkins pipeline script and it has to read the contents from a properties one by one which is having as a key-value pair. I need to split key and value separately. Below are the properties and groovy file which I am using. To be read file…
Kivi
  • 485
  • 1
  • 9
  • 26
1 2 3
99
100