Questions tagged [jenkins-groovy]
Question regarding using groovy code in Jenkins, specifically in Jenkinsfile and groovy plugins
2,862
questions
0
votes
0
answers
6
views
How to update the release specific dependency automatically in Jenkins with Maven as Build Tools
We have a maven project producing the jar as artifact(Let Say Module-1).
We are maintaining multiple branch for this project.
This jar is used inside the mulitple other maven project as dependency ...
0
votes
0
answers
13
views
Grovvy script filename
How do I get the name of the current Groovy script filename? It's a Jenkins scripted pipeline.
Tried, but didn't work:
this.class.getName()
this.class.name
getClass().protectionDomain.codeSource....
0
votes
0
answers
19
views
Is there a Jenkins readFile plural equivalent? Like readFiles?
I am trying to utilize jenkins to read files into the output for multiple boxes. With the tools that I have used I am now successfully writing the input for the readFile into several files. I would ...
0
votes
0
answers
16
views
Unable to do operation on running pipeline's log
Running sonar scan to scan the build. Scanning working fine but want to check Sonar way profile got used to scan the project, if not then pass the pipeline with warning message.
I thought to get the ...
0
votes
0
answers
14
views
How to count number of functions in particular stage and pass that count to manager.removeBadge(count) in jenkins pipeline
i am a beginner and while exploring came across manager.addshortText and remove.Badge() and I want to know how we can count functions / manager.shortText in particular stage in pipeline. So that when ...
0
votes
1
answer
66
views
How to pass build parameters to shared library, and set env variables there
I have a declarative pipeline, that is making use of shared library to zip the checked-out repo, and set some environment variable like env.VERSION. The pipeline uses build-parameters to run.
I am ...
0
votes
0
answers
26
views
Disable logging of Jenkins functions in Jenkins Blue Ocean
When using the Jenkins functions readJSON and httpRequest in my groovy file for a Jenkins pipeline step, this gets shown as a row in Jenkins Blue. Is there any way to disable the logging of these ...
0
votes
1
answer
38
views
Does using the load step to load a pipeline block still count as a declarative pipeline?
I have two Jenkins jobs that use two Jenkinsfiles that are "almost" exactly the same, so I wanted to abstract the Jenkinsfile into a common one.
// commonPipeline.groovy
def buildImage(...
0
votes
0
answers
10
views
can we use visual icon like arrow mark in Jenkins stages?
when moving from one stage to another , instead of asking yes or no or password to proceed to next stage in Jenkins. can we have visual icon like arrow mark ?
so that after clicking in the arrow mark ,...
0
votes
1
answer
29
views
How to get failure causes of current build in Jenkins using Python?
I want to implement currentbuild.rawbuild.getcauses() in Python. How can I do that? The functn is presently a part of groovy script which needs to be converted to Python.
I don't seem to find anything ...
0
votes
0
answers
36
views
How can you run parallel jobs on a scripted Jenkins pipeline?
I've got a parent pipeline that triggers another one. I'm using build job: here. When the pipeline runs, the pipeline triggers the the child job but the child jobs run 1 by 1, waiting for each one to ...
0
votes
0
answers
19
views
To Finish the launch created in the report portal from the Jenkins pipeline (Post build action)
I have used the curl command to finish the launch with the launch id from the report portal and tried executing in bash. To use this in jenkins pipeline.
It returns :
% Total % Received % Xferd ...
0
votes
1
answer
50
views
How to select jenkinsfile depending on branch name
I have a single large code base which is using for build and deployment apps for different countries.
Each country has its own unique building/deployment pipeline.
That's why I would like to specify ...
0
votes
0
answers
30
views
Empty body when sending success email with Jenkins
I have this fragment in my Jenkinsfile
post {
success {
mail to: '[email protected]',
subject: "The email subject",
body: "Something very interesting",
charset: ...
0
votes
1
answer
22
views
pass values between methods in shared libraries in Jenkins Templating Engine
I am trying out Jenkins templating Engine, my governance Tier has the following Jenkinsfile
node("Build-Node") {
def artifactVersion
checkout()
build()
sourceArtifact = docker_build()
push(...
0
votes
0
answers
17
views
Runing the blueocean plugin within a JenkinsPipelineUnit testcase
I'd like to use JenkinsPipelineUnit to test our Jenkins pipeline. We use the "blueocean" plugin in production. So, to test our Jenkins pipeline file, I need to do this:
import io.jenkins....
0
votes
1
answer
24
views
How to read which pipelines a user is allowed to run as downstream jobs in Jenkins
I want to add a feature in my groovy script to allow users run other jobs sequencially once the job they have selected has finished if they input the name of the job in a text field created for such ...
-1
votes
1
answer
34
views
Upload large(mb) files from jenkins GUI to respective build workspace
I have a scenario where i need to upload large (mb’s) file from Jenkins GUI to workspace?
Is there a way to achieve this request?
Please let me know the available solutions.
File should get uploaded ...
-1
votes
0
answers
15
views
jenkins pipeline dynamically generate stages based on concurrent limit
Currently, in a repository, we have (say) 15 "Test" folders, we do have jenkins pipeline where we added all 15 stages (parallel), this will execute all 15 tests in the cloud. Due to the ...
0
votes
1
answer
179
views
Jenkins Pipeline: java.io.NotSerializableException with XmlUtil.serialize
I'm facing an issue in my Jenkins pipeline where I get a java.io.NotSerializableException when using XmlUtil.serialize.
Code Snippet:
de updateFile() {
def file = readFile(file: filePath)
def ...
0
votes
0
answers
26
views
Use a changeset condition with if
Can we use a changeset condition with if in Jenkins
if (changeset "**/ml/docker/Dockerfile-dataproc-pp") {
echo "Pushing all docker images with all tags to GCR"
}
When I ...
0
votes
0
answers
24
views
hudson.plugins.git.UserRemoteConfig contains null values in RefSpec, but Jenkins has actual values
If I run the following in the Jenkins Script console:
String jobName = "path/to/myJobName"
def workflowJob = Hudson.getInstance().getItemByFullName(jobName)
def currentRun = workflowJob....
0
votes
1
answer
22
views
Parsing Jenkins console output errors
I need to detect the errors of console output(pipeline/stage failure, java exceptions, etc...) of a jenkins pipeline and make a report to send it to my team.
I tried to find a suitable plugin but they ...
-1
votes
0
answers
12
views
In Jenkins Pipeline, how can I call a downstream job which has field parameter Stashed File Parameter, how can I call that
From my parent job, say I want to call a downstream job which has parameter type of Stashed File.
My code snippet is:
child_job = build job: 'test_job_file_upload',
parameters: [...
0
votes
0
answers
19
views
Jenkinsfile Username and Password credentials cannot pass over to Packer
I had
Jenkins ver 2.401.3
Packer 1.9.4
Below is my Jenkinsfile
pipeline {
agent any
environment {
AWS_CRED = credentials('AWS_SECRET')
}
stages {
stage('Packer - Build Ubuntu ...
0
votes
1
answer
40
views
Adding multiple reference parameter for a single active choice parameter in Jenkins
I'm trying to add multiple reactive parameter for a single active parameter. But when I implement it in Jenkins Pipeline, 2nd reactive parameter is going fallback script. But when I tried to do the ...
0
votes
0
answers
32
views
Create a issue or bug in JIRA using jenkins pipeline whenever test cases fails
I tried multiple ways to create the task or bug in JIRA using Jenkins pipeline however its not working. Its doesn't show any log about jira issue creation. Please help me on this
pipeline {
agent any
...
1
vote
1
answer
104
views
run a parallel thread in a pipeline that does not appear to be a stage or a closure
I have a pipeline that runs let's say 50 parallel stages. In each stage, I'm starting a python script (using the sh, or bat steps) which runs all the logic required for that stage. This same python ...
0
votes
1
answer
52
views
if else condition is not working in Jenkinsfile
So I'm trying to use the if-else condition in my scripted Jenkinsfile to run the builds depending on the choice parameters that are being passed at the beginning of the pipeline. On passing pt as ...
0
votes
1
answer
43
views
In Jenkins pipeline, how to display a Groovy map's contents in an email body?
I have a Jenkins declarative pipeline that executes parallel stages. The exit code of each stage is assigned to Groovy map results and printed to the log console:
def p = [:] // map for ...
0
votes
0
answers
33
views
Jenkins Pipeline include stages in a body
I would like to create a shared library with common steps but just one stage in different for instance build maven and build npm.
And I'm imaging it like this
def pipe(Map args, Closure body) {
...
-1
votes
0
answers
27
views
How to add additional sh commands inside each stage along with the reusable function in Jenkins
The below is my pipeline script, I wanted to wrap couple export commands into a function and call it to avoid rewriting the export commands. However, every time I called the function, the shell could ...
-1
votes
1
answer
18
views
Script function failed on Automation for Jira rule:IllegalArgumentException: wrong number of arguments
I am trying to use the HAPI API for Scriptrunner and I am getting the following error:
My code is very simple, I am using the following:
Collection < ProjectComponent > ...
0
votes
0
answers
29
views
How do you get git committer description for Jenkins pipeline
I have a pipeline set up in groovy and need to pull the complete description committed some code in git so. I've searched the web and can't seem to find a solution. I can get the title committed but ...
0
votes
0
answers
18
views
How to create choice parameter for load test?
we have jenkins pipeline written on groovy script from code checkout, image build, unit test, code quality,securityscan, push to registry and load test
my requirement is as load test stages should be ...
0
votes
0
answers
14
views
In Jenkins declarative pipeline: failure to iterate through list in for loop
I'm trying to understand what is happening here in Jenkins pipeline script. I have this code which is taking a list of values (originally strings but changed to try to simplify/troubleshoot), ...
0
votes
0
answers
40
views
How to call powershell script from groovy
I have a working jenkins pipeline script and added a call invoking powershell script. This works, if I hard-code the path. But if I use the variable, (modeled based on the bat call), it errors. What ...
0
votes
1
answer
31
views
Jenkins trigger on Pull request merge?
When some repository has PR that is merged, how I can
listen to that event and trigger Jenkins job on Merged PR.
Also is it possible with keeping cron job as one of the triggers.
Thanks in advance
...
-2
votes
1
answer
33
views
Groovy conditional simple logic in Jenkins pipeline
In the Jenkins pipeline, a simple "if" condition is not working.
The "if" condition is in groovy. And if the action is "Plan", the if condition is getting skipped. any ...
0
votes
0
answers
42
views
Jenkins multibranch pipeline that creates multiple jobs with shared libraries
I have an environment with multibranch pipeline and shared libraries.
Scanning and creating jobs is working like the following example:
JenkinsFile:
deployKubernetes()
I am trying to create 2 ...
0
votes
1
answer
57
views
How to fetch key/value from library function in Groovy script
I am trying to create a library in Groovy that can create a JIRA issue from Jenkins. I am able to create the issue, but how can I redirect the function output to a variable to filter specific key/...
0
votes
2
answers
84
views
Replace a string value from json file in Jenkins pipeline
I want to replace the value of "version" from the below json file with a variable I defined already in Jenkins pipeline.
{
"name": "new-relic",
"version": &...
0
votes
0
answers
19
views
Unable to execute commands in Jenkins using open SSH in Window server even though able to execute that same command in cmd
I am going to create Jenkins pipline but with different scenario please share your experiance to resolve error.
So the scenario is :
Jenkins is installed in the Mac machine.
My project is in .Net ...
0
votes
0
answers
24
views
Try-Catch Retry 3 times using different node each time
I have a try catch within a stage and I want to retry it 3 times, each time using a different VM but I'm running into issues.
I have managed to make it try running on 3 different VMs however I am ...
0
votes
0
answers
40
views
My Jenkins pipeline is getting success even if the job fails
The stage which I pasted below is the issue. The curl command produces 401 bad credentails but the jenkins job is getting success. How can i make this job fail if the logins are not correct.
stage('...
0
votes
1
answer
26
views
DSL Script `suppressFolderAutomaticTriggering` property isn't working
I wrote the following script to create jobs in Jenkins automatically.
According to this video i can stop a build storm by adjusting the suppressFolderAutomaticTriggering property.
But when I run my ...
0
votes
0
answers
37
views
jenkins: failed to access to the workspace from Groovy libraries on a Windows agent
I'm running a pipeline on a Jenkins agent running on Windows Server 2016, this pipeline is using a Jenkins library to download file from local server. The download is done with a method using curl and ...
0
votes
0
answers
25
views
How to pull dependencies from protected artifactory using grapes in groovy?
I want to pull dependencies from jfrog artifactory, Artifcatory mandates authentication with access token. Couldnt find a way to pull jars with credentials.
0
votes
0
answers
38
views
Jenkins shared library writeFile pom.xml
Why i can't do this with pom.xml file?
Always get error: No such library resource my_pom.xml could be found.
def call() {
def mvnPomXml = libraryResource encoding: 'UTF-8', resource: 'my_pom.xml'
...
0
votes
0
answers
96
views
Jenkins Issue fatal: unable to access : URL using bad/illegal format or missing URL
My problem lies in the last stage of my Jenkins Pipeline, where Jenkins is expected to commit the updated pom.xml file to our application repository hosted on GitLab.
Below are the necessary data.
...