Question regarding using groovy code in Jenkins, specifically in Jenkinsfile and groovy plugins
Questions tagged [jenkins-groovy]
2809 questions
5
votes
1 answer
How to list the jenkins jobs script path programmatically
I'd like to create a groovy script to run on the jenkins console to list the job definition with the repository used and the script path (the jenkinsfile), with an output like this:
JobName -> git repository -> script path
So far I was able to list…

Mikyjpeg
- 1,179
- 1
- 13
- 39
5
votes
1 answer
How to translate groovy map to json
I have the below code in Jenkins pipeline:
stage ("distribution"){
steps{
script{
def rules = [
service_name: "core",
site_name: "*",
…

arielma
- 1,308
- 1
- 11
- 29
5
votes
1 answer
How to run a Jenkins pipeline multiple times, based on the multiple/different parameters. (Please refer the description for more details)
I have a string parameter used in pipeline.
names="name1,name2" (In a single textbox, User will enter the names separated by commas)
I am converting this string to list using tokenize method. After this, list will have [name1, name2]
I have a…

Kanaga Manikandan Gopal
- 141
- 2
- 3
- 9
5
votes
1 answer
How to configure Jenkins to @Grab dependencies from Artifactory in sandboxed pipeline script
I'm able to use @Grab annotation in Jenkins pipeline script in both, sandbox and non-sandbox mode. My problem is that dependencies are by default resolved against maven central repository but I need to get them resolved against our company…

user1952557
- 91
- 7
5
votes
1 answer
how to fix - stageResult set to FAILURE but still get success in jenkins
I'm trying to create a very simple pipeline,
it has one stage and one step.
it uses the job 'build' I created as freestyle (which works) but I added an error (the parameter project name has a wrong value - 'test3' instead of 'test')
when I ran it,…

JHON SMITH
- 103
- 1
- 1
- 6
5
votes
1 answer
Constructor not called in Jenkins Shared Libraries
I am trying to develop shared libraries and has the following directory structure
src/com/mycomapny
MyTest.groovy
vars
test.groovy
Jenkinsfile
my Jenkinsfile calls only method available in the test.groovy with required input. which imports…

yashwanth ssc
- 51
- 1
- 4
5
votes
0 answers
Jenkins is not updating pipeline parameters after multiple runs
Jenkins version: 2.176.1
Our Jenkinsfile's parameters have changed over time and I've noticed that old parameters are still offered in the GUI and a new one isn't. This is still the case after multiple runs. We use a multi branch pipeline. New…

David Williams
- 401
- 3
- 15
5
votes
2 answers
how to fix JNLPLauncher exception in jenkins pipeline
We have script that use vSphere to do revert-snapshot to machine and turn on.
And then we check if agent available like this:
def checkAgentAvalability(agName, tolerance) {
try {
int sleepTime = 5
def jenkinsObj =…

Zakk
- 758
- 3
- 11
- 20
5
votes
1 answer
Declare configFileProvider only once in JenkinsFile and reference from all stages
I am trying to set up scripted JenkinsFile for our pipeline automation and would like to use configFileProvider for maven. As such i end up defining this block in all maven stages within the scripted JenkinsFile.
Is there a way to define it just…

Ashley
- 1,447
- 3
- 26
- 52
5
votes
1 answer
How to compile Jenkins Pipeline Groovy locally?
Does anyone have the magic maven/gradle invocation to compile a set of jenkins pipeline DSL groovy files?

Christian Goetze
- 2,254
- 3
- 34
- 51
5
votes
2 answers
How to use groovy env. variable in Jenkins to pass through bat command in Jenkins pipeline
I have stage in my jenkinsfile, that executes a bat command:
stage ('build'){
bat '%cd%\\MySimpleProject\\bin\\Execute.bat "${env.BRANCH_NAME}"'
}
My batch command requires a parameter that is the current branch in svn.
When I use this:
echo…

user1670340
- 129
- 1
- 2
- 13
5
votes
1 answer
Error Slack Send Pipeline step configured values from global config
I have downloaded & installed Slack Notification Plugin in jenkins and using slackSend in the pipeline, it was working before but now getting an error as below: After this i downloaded Global Slack Notifier plugin, but still the same error,is there…

Smi
- 183
- 1
- 4
- 12
5
votes
2 answers
Jenkins Multibranch Pipeline fails because it runs in Groovy Sandbox
My Jenkins CI/CD build configuration was working and nothing changed until my last pull request and I need to get this working again.
The Multibranch Pipeline is configured to run a jenkinsfile from BitBucket SCM but this is now failing with the…

Dave Anderson
- 11,836
- 3
- 58
- 79
5
votes
1 answer
Jenkins : Groovy : Scripts not permitted to use method groovy.lang.GroovyObject getProperty java.lang.String
org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException:
Scripts not permitted to use method groovy.lang.GroovyObject
getProperty
java.lang.String
(com.cccis.telematics.build.Templates.run_jgitflow_template)
at…

Jeff Maass
- 3,632
- 3
- 26
- 30
5
votes
1 answer
How to execute shell from Active Choices Plugin groovy script in Jenkins
I am trying to render information obtained from the shell in an active Active Choices parameter with a groovy script. I can easily access the shell from a groovy script in a jenkins pipeline with the sh method like this:
node()
{
sh 'git log…

CurlyFire
- 712
- 2
- 6
- 18