Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkinsfile DSL sourcecode

I am developing new pipeline within Jenkinsfile using intelliJ.

When I was using jenkins 1 with pipeline-dsl plugin I could go into the source code and see how DSL was actually implemented in org.jenkins-ci.plugins:job-dsl-core. I would like to have the same ability with Jenkinsfile.

Can I somehow connect Jenkinsfile DSL and intellij to have there proper code completion and sourcecode insight?

like image 936
Igor Konoplyanko Avatar asked Apr 28 '26 07:04

Igor Konoplyanko


1 Answers

In order to have access to the sourcecode for the Pipeline Plugin suite of plugins when working on ANY Jenkins pipeline script, whether global or otherwise, you will have to include the necessary libraries as dependencies.

I'm working on my current global pipeline library. Global Pipeline Library as IntelliJ Project and Module

Here adding the CPS library via "Project Structure" menu item: enter image description here

  1. Go to Libraries
  2. Click the add button and select "From Maven..."
  3. Type in the correct GAV (in this case com.cloudbees:groovy-cps:1.9)
  4. Click the magnifying glass button - IntelliJ will search Maven Central (and whatever other repos you've configured in the Maven IntelliJ configuration or via your settings.xml) and download them to an your local cache.

Rinse and repeat until you've got all the dependencies you need.

When you're done, it should look something like this: Groovy CPS library added to Groovy project

I found that the minimum useful were:

  • com.cloudbees:groovy-cps:1.9
  • org.jenkins-ci.plugins.workflow:workflow-api:2.+
like image 156
rbellamy Avatar answered Apr 30 '26 21:04

rbellamy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!