Questions tagged [jenkins-groovy]

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

2809 questions
0
votes
1 answer

Job DSL plugin | Shared Library | Pipeline jobs | Github Hook not working

Please bear with me the description might be long but it might give a clean picture of the intent and issue. I have used Job DSL Plugin to create a seeder job, which in turns creates two new Jobs. I have 2 separate repositories For maintaining…
0
votes
1 answer

not able to install Groovy in windows 10

I am trying to install Groovy on windows 10. I have Java 17.0.4.1 installed and trying to install groovy 4.0.5 & here is the link (https://groovy.jfrog.io/ui/native/dist-release-local/groovy-windows-installer/groovy-4.0.5/) after installation I…
santosh
  • 192
  • 9
0
votes
1 answer

Jenkinsfile Switch case with contains is throwing CpsCallableInvocation error

I am trying to write a jenkins file with a switch case, where I am trying to use string operations in case. In a regular groovy it is working fine but in JenkinsFile it is throwing errors. What am I missing? Code switch (env.UPSTREAM) …
0
votes
1 answer

Defining agent labels in a single separated file

I am currently facing a problem, I have about 90 jenkinsfile, we recently updated one of the Jenkins agent and it has a new label now, which means that we have to go and update every jenkinsfile with the new label of that agent, you agree that this…
ema
  • 21
  • 5
0
votes
1 answer

Need to check if folder exists in workspace in groovy script for jenkins pipeline

I need to check if a specific folder exists, I can not give the full path as some of the folder names will be different each time. I used the below code - echo "checking if folder exists" def files = findFiles glob: '**/*example*' echo…
0
votes
0 answers

jenins grovy to call sh script

Hi I have the following groovy script that I want to use to build a project in Jenkins #!/usr/bin/env groovy def deploymentPaths = '[]' pipeline{ agent { label 'jenkins-agent' } stages{ stage('Build debug'){ steps{ …
W Nguyen
  • 45
  • 7
0
votes
1 answer

Jenkins pipeline Parellel steps needs to run based on the previous step

This is the Jenkisnfile script currently i am using to run my pipeline for the NodeJS applications. it's working well and suited to my previous pipeline process. Now I Need to change a little bit in my script for the New Project Requirement. In the…
Ojer_Dev
  • 108
  • 1
  • 12
0
votes
1 answer

How to check all files in a directory except one file in Groovy language

I am trying to search a word in every file in a directory but I want to exclude my logfile. My code is something like this user input: search test C:\Users\Desktop\test\Groovy My code import static groovy.io.FileType.FILES import…
bjhayeyy
  • 79
  • 12
0
votes
1 answer

How can I create scoped environment variables in my Jenkinsfile?

The Jenkins credentials plugin provides a withCredentials function that can store the value of a credential into a scoped environment variable as seen here. node { withCredentials([usernameColonPassword(credentialsId: 'mylogin', variable:…
0
votes
1 answer

Jenkins @Libs adds folders after jenkins update

I'm migrating an old Jenkins buildserver i did not set up to a new updated version and that broke the groovy scripts since it's not naming folders in the @libs the same way it did before, maybe it's some setting that is changed. @lib structure on…
Timmy
  • 52
  • 1
  • 2
  • 8
0
votes
1 answer

Get real Build Number from Jenkins API

I try to select all current running processes to get the BuildNumber an JobName of the running pipelines to finaly have the possibility to kill them. However, if I use the Jenkins API to collect the BuildNumber and JobName I will get as…
IFThenElse
  • 131
  • 1
  • 10
0
votes
1 answer

Jenkins Extended Choice Parameter with groovy shell command

I try to collect data for an Extended Choice Paramater. I use the code: def ingo = sh(script: 'mktemp', returnStdout: true) return ingo inside the groovy script part, but it seem that this is not allowed or well formated. The choice is always…
IFThenElse
  • 131
  • 1
  • 10
0
votes
1 answer

Groovy Invoke Map.variableName expecting variableName to be replaced with corressponding value NOT working

I have a groovy script code, result = new JsonSlurper().parse(.newReader()) echo $result.propertykey Note : result is a Map which contains multiple key value pairs including propertykey1:propertyvalue1 Output…
Vijay Kumar R
  • 41
  • 1
  • 1
  • 4
0
votes
1 answer

In jenkins how to restrict users to select first default element with other options in extended choice parameter

I have a jenkins job with multi select extended choice parameter. There are list of elements in a parameter. So, my requirement is I want to allow users to select multiple parameters excluding first element in a parameter. Means user should not able…
svw1105
  • 127
  • 1
  • 15
0
votes
1 answer

Active Choice Parameter with Azure VM LIST

I'm trying to create a VM list out of active choice parameter: def command = 'az vm list --resource-group test-test-test \ --query '[].{computerName:osProfile.computerName}' \ --output tsv' def proc =…
WhoAmI
  • 1,013
  • 2
  • 9
  • 19
1 2 3
99
100