Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [groovy]

For questions about Groovy, which is an object-oriented programming language for Java.

0
votes
1answer
8 views

How to assign saltstack pillar values from Jenkins comma separated input parameters?

I have a Jenkins job with string parameter as target "server1,server2". Jenkins pipeline script is expected to execute the job on server1 and server2 respectively. There is a common salt sls file that ...
-1
votes
0answers
48 views

Convert Jenkins job DSL to pipeline groovy

Here is the sample code: out.println "-------------------------" def param = params['Project'].toString() out.println 'Building COMM ' + param + ' project: ' out.println 'Checkout a source code and ...
0
votes
1answer
23 views

Does Jenkins job create Jenkinsfile? On execution

On creation of a new job(as free style project), and running it, I see that Jenkinsfile is generated in job's workspace, after running the job. But I see that all the pipeline code is commented. ...
0
votes
1answer
102 views

How to define global variables in groovy file, which I want to load and consume?

I have a Jenkins parent groovy file which consumes the child groovy file Parent grooy file: ... def child = load 'child-groovy-file'; child.execute(); Child groovy file: a = "first letter"; b = "...
1
vote
1answer
194 views

Groovy script to show only selected item

I used jenkins Active choices plugin and Mavenmetadata plugin to build above UI. When I click a radio button particular version only should be display. How can I write a groovy script to fulfill above ...
1
vote
0answers
41 views

Pass Variable in pipeline script

I am trying to pass a variable input to "credentialsId: $creds" from SiteID but unable to. I tried multiple expressions in pipeline script with quotes etc and none worked. I am learning and need ...
3
votes
1answer
1k views

Jenkins Groovy to parse console output and mark build failure

What would be a Groovy or pipeline step to parse Jenkins console output, identify a string and mark the build as failure if the string is matched?
2
votes
3answers
330 views

Jenkins UUIDs … oh the humanity

I have an environment block environment { SUITE_RUN_ID = UUID.randomUUID().toString() SMOKE_CMD = "runtests.sh SUITE_RUN_ID=${SUITE_RUN_ID}" FAILED_TESTS = "output_rerun_info.rb SUITE_RUN_ID=${...
3
votes
1answer
2k views

Get changes of the parameterized pipeline on the fly in Jenkins

Is it possible to get changes of the parameterized pipeline on the fly after making changes there? For example I have a pipeline code: properties([ parameters([ string(name:...
1
vote
1answer
271 views

Compatibility of http-builder-ng Groovy module with Jenkins 2

Did somebody had a chance to use http-builder-ng Groovy module in Jenkins pipeline? When I use this module with any kind of request/URL it always returns me null object when the same source code ...
2
votes
1answer
634 views

How to set a Git repository when creating a job in Jenkins from a Groovy script?

I'm trying to setup a Jenkins server with Groovy script: def repository = 'git@somerepo' import hudson.tasks.Shell; job = Jenkins.instance.createProject(FreeStyleProject, 'TestJob') job....
3
votes
2answers
2k views

How to check return status of parallel branches in jenkins pipeline

I am running a Jenkins job on multiple slaves. Following is the code structure: def branches = [:] def allNodes = Jenkins.getInstance().getNodes() for (int i =0; i < allNodes.size(); i++) { ...
5
votes
2answers
2k views

Jenkins libraries configuration in Jenkinsfile

Right now we have many projects with similar Jenkinsfile's. Instead of copypasting we're developing a shared library with some utilities. This library is loaded dynamically in each Jenkinsfile, and ...
5
votes
3answers
1k views

Jenkins Pipeline downstream job; exit unless it hasn't run in the last x hours

Is there a way in Groovy directly or by integrating Jenkins plugins to have a downstream job complete only if it hasn't been run in the last X hours already? Let's say I have unit tests, when green, ...
37
votes
3answers
56k views

Cleanest way to prematurely exit a Jenkins Pipeline job as a success?

I have a job that will create files, unless one of the values being fed to it matches an older value. What's the cleanest way in Jenkins to abort or exit the job, without it being FAILED? It exiting ...