I am facing issues with active choice and reactive choice parameter groovy script in jenkins.
Existing groovy script which was working previously, now has the issue as a result I cannot pass the input correctly within the job.
Is there a possible way to troubleshoot this groovy as we don't have any IDE and jenkins compile those scripts internally.
Do you know about the script console at https://your-jenkins-server/script ?
Related
I have a shared library repository that contains all of my shared functions.
Is it possible to somehow use this within a freestyle job?
What I'm trying to accomplish is to create a freestyle job that calls and executes code from the vars folder of my shared library repository.
Is this possible at all?
Freestyle jobs have a Execute Groovy Script Build Step and I wonder if it might be possible to write a groovy script that calls a function within a global shared library.
I've tried to call the function using
GroovyShell shell = new GroovyShell()
def tools = shell.parse(new File('demoFree.groovy'))
tools.call()
demoFree.groovy being the name of the file that holds the function but my Groovy knowledge is very limited so I'm probably doing something very wrong.
I know this is easily done using a pipeline project but I'm having to deal with a legacy freestyle project which for a number of reasons isn't being moved to a declarative pipeline just yet.
No. According to the Documentation shared libraries are meant to be executed only from Jenkins pipelines.
However, you can easily create a pipeline job, choose Pipeline Script (instead of Pipeline from SCM) and write the code you need that uses your library.
You will find it much more convenient that using a FreeStyle job.
I'm considering the option to use Jenkins Pipeline to build data ETL pipelines. For the moment, it sounds more attractive, more modern and simpler to use than Make/Makefile.
However, I don't understand if the same Make/Makefile step-triggering behaviour is available, eg, let's say I have data2.xml built by the script csv2xml.sh, taking data1.csv as input: in a Makefile, it's pretty straightforward to declare that data2.xml must be built only if it doesn't exist or is older than data1.csv.
Is it possible to do the same in Jenkins Pipeline? Or am I looking at the wrong tool?
such steps are available under sh/bat execution, you can deal with your make/makefile as usual , Jenkins will just execute it and give you back results, afterwards inside pipeline you will decide what to do with it, e.g. upload to server or something similar
In Jenkins, is it possible to export windows batch variables as build parameters? I know using build parameters inside windows batch blocks is, I use it a lot.
For example, I have a windows batch block that creates a variable, say A, like
SET A="MyVar"
Is it possible to use it in running MSBuild, passing it like it was a build parameter, in the (working) syntax of /p:AssemblyName=%A% or /p:AssemblyName=${A} ?
Neither of these seem to work (my variable is always empty).
Update: #Tuffwer suggested using the EnvInject plugin. I have been trying, but so far without success. Here's a sample I created to illustrate my original intent:
I want to create a variable which contents will be determined based on a condition applied in one of the build parameters. Then, I want to use that variable as a parameter to the MsBuild command line, using the /p:[Key]=[Value] syntax (which requires the Jenkins MsBuild plugin, if I am not wrong).
I still can't get this to work, now using EnvInject. I need to reference the value of a windows batch variable inside a further build step.
Update II: I turned into Environment Script Plugin, which did the job for me.
Tuffwer suggested using the EnvInject plugin, I tried did not succeed attaining what I intended. I edited my post including my EnvInject attempt, but in the meantime went searching again for other solutions.
This time I came across the Environment Script Plugin, which did the job for me.
Steps:
Mark Generate environment variables from script
For each variable you want to "export", you need to issue an echo [varName]=[value] statement.
That's all.
My build then creates an assembly named either TRUE.exe or FALSE.exe, depending on the build parameter MyBool value.
I am using this plugin: https://developer.ibm.com/urbancode/docs/integrating-jenkins-ibm-urbancode-deploy/
Is there a way to push to multiple components in UCD from inside one Jenkins job? e.g. The same Jenkins project compiles Java and produce three components: app1_web, app1_ear, app1_db in UCD. I see the plugin inside the Post Build Action can only be inserted once in the same job. Guess this is a question in Jenkins.
If you use Pipeline rather than the old Freestyle job type, you can use post-build actions multiple times.
Though I don't know which plugin you're using, and whether it supports Pipeline.
I am unable to retrieve the Job name using groovy script below. Even when I run this script in the Execute System Groovy Build Step, it gives me the error as.
Error:
groovy.lang.MissingPropertyException: No such property: jenkinsProject for class: groovy.lang.Binding
----
def jobName = this.binding.jenkinsProject.name
----
I found in the below link that it has worked for someone, but somehow not working for me. Can anyone help please?
How to get the job name on a groovy dynamic parameter in Jenkins
The v1.3 and v1.4 (released in a couple of days once manual testing is done) both should support this feature. Just use jenkinsProject in you code and that should work fine. Other wise just let us know via issues.jenkins-ci.org, component=active-choices-plugin.
The v1.4 has a bug fix that allows you to use this variable with Matrix projects as well.
Hope that helps,
Bruno