Schedule job based on parameter? - jenkins

I'd like to start a build for a job named project-${X} where ${X} is given by a parameter of the current build. Does this work, maybe with a plugin?
Thanks,
Carsten

Parameterized Trigger plugin has that feature. You need to use the latest version (2.15) - there seems to be a bug in earlier versions.
Your other options seem to be Python JenkinsAPI wrapper or Groovy run via Groovy Plugin that accesses Jenkins via its Java API.

Related

Groovy 3 and Jenkins Embedded Scripting?

I've just started playing around with Jenkins - and I'm looking at Pipelines.
I'm looking to brush-up on my Groovy skills to facilitate this.
The latest literature is all "Groovy 3" based and comes with some significant new features, but despite having the latest Jenkins install (Jenkins 2.249.2), the embedded scripting engine seems to be older - from Jenkins' script console on my master:
println GroovySystem.version
Gives 2.4.12.
My question - Is the version of Groovy easily/sensibly configurable in Jenkins or is it usual to stick with whatever ships with Jenkins?
You must choose system groovy if you want ready access to the Jenkins internals, jobs, etc. See Groovy Script vs System Groovy Script, and Known limitations; you get what is packaged.
If you use external groovy and don't need to access Jenkins internals, your choice. Lots of internal debate on upgrading as it's lots of work. You can follow JENKINS-51823 and Pipeline Groovy Epic

Is it possible to use external jars via #grab from inside the Jenkins groovy postbuild plugin?

I want to send some specific notifications (REST API) back to our server, which triggered our Jenkins build jobs via REST API. For this, I am about to include a jar of our own, which has a lot of convenience methods in it.
I am able to use the jars inside the Groovy Script by utilizing #Grab, that's fine.
But it doesn't seem to work from within Groovy Postbuild Plugin.
It even doesn't recognize referenced script files from within another package, which is next to the script file.
Is there a workaround? How can I send my specific notification using java or groovy and the methods provided in our own jar? Do I need to write a Jenkins Plugin for this (hope not). Thanks in advance, Anne
I would actually recommend to changing your jobs over to Jenkins Declarative pipeline. Then you can use the post handling built into the Jenkins pipeline language. You then have some options. You could use the pipeline steps provided by the HTTP Request plugin to call REST APIs, create a Java tool to call your REST APIs using your Jar library (install as a custom tool which can be used from pipeline) or write a custom plugin to provide the pipeline steps. If you decide to write a plugin have a look at the Webhook Step plugin for how to do it - https://github.com/jenkinsci/webhook-step-plugin. Your best bet might be a custom Java command line tool called from a pipeline shell step (sh or bat) depending on the agent / slave OS you use.

How to pass parameter in rtc plugin Jenkins

I am using RTC plugin for get source from IBM Rational Teamconcert in Jenkins, but how can I pass the parameter that I declared using This project is parameterized plugin like the image below
I used %variable_name% but not successful.
You can see an example of a String parameter used in the Job Configuration section of this plugin.
However, make sure your Jenkins is running on Windows if you want to use %A_VARIABLE% syntax.
If it runs on Linux, that would be ${A_VARIABLE}.

Is it possible to use Jenkins without Groovy

I've used Jenkins long ago and few days ago I've tried the current version. It seems that all build instructions now are made by Groovy scripts. I can't find in Jenkins documentation if it is possible to do it in the old way using UI? I believe Groovy has advantages but I don't know Groovy and old Jenkins functionality was enough to me.
you need to choose freestyle job and then you can use it the old way

Configure block equivalent for Jenkins 2.0 Pipeline

For the Job DSL Plugin (https://github.com/jenkinsci/job-dsl-plugin) you can script your Jenkins jobs using this plugins DSL script with the help of their built in methods to support most plugins.
When you encounter a plugin that is not yet supported you can still use it by using a "Configure" block (https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block) that tells the plugin how to build the XML manually.
Is there an equivalent feature for the new Jenkins 2.0 pipeline (https://jenkins.io/solutions/pipeline/) to support plugins that are either not updated often or at least until the plugin author adds support?
You should have a look at new Jenkinsfile capabilities. In essence, you can now configure your entire job using the Jenkinsfile and pipeline approach.

Resources