Igor Konoplyanko
Igor Konoplyanko

Reputation: 9374

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?

Upvotes: 3

Views: 4557

Answers (2)

rbellamy
rbellamy

Reputation: 5833

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.+

Upvotes: 5

Eugene A
Eugene A

Reputation: 330

Have you tried this approach yet?

Upvotes: 3

Related Questions