System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Amedee Van Gasse
Following up on my previous question about a System Groovy Script.

I have a .groovy file in a git repo.
I have cloned the git repo to my pc.
I have opened the directory in IntelliJ IDEA.

Now I get a lot of red text. None of the imports are found.
It looks like this:

import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction


How do I configure IntelliJ IDEA so that I no longer have red alerts on the imports?

For the record: I did not write this code. I have been asked to maintain it, and fix a bug.
It's my professional opinion that all code should be under version control, and I don't want to edit the code directly on the Jenkins web pages but in a IDE so that I have syntax checking, autocomplete, and all the other usual conveniences.

You are allowed to assume that there are only 3 files in the repository: a .groovy file, a .gitattributes and a .gitignore. I do know how to write code in the Groovy language, but I don't know how to set up a Groovy project. As an analogy: I know how to fly a plane, but I don't know how to take off or land.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/508faaef-497b-4914-b0d4-5522da131cf9n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Amedee Van Gasse
Answering my own question for at least the hudson.* and jenkins.* imports:

* download jenkins-core for my Jenkins version from https://repo.jenkins-ci.org/ (in my case: version 2.263.3, so I need https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-core/2.263.3/jenkins-core-2.263.3.jar)
* save the jar in a directory lib
* add the jar as a library to my project

Now, at least for the hudson and jenkins imports, IntelliJ doesn't complain.
I think I'll have to repeat for the Workflow plugin?

Now, I know that this is the really old fashioned way of doing it, from the days of yore from before dependency management.
I'd prefer not to have the lib folder with jars added to git.

What would be a nice dependency management ish way of doing it?


On Tuesday, February 16, 2021 at 1:08:01 PM UTC+1 Amedee Van Gasse wrote:
Following up on my previous question about a System Groovy Script.

I have a .groovy file in a git repo.
I have cloned the git repo to my pc.
I have opened the directory in IntelliJ IDEA.

Now I get a lot of red text. None of the imports are found.
It looks like this:

import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction


How do I configure IntelliJ IDEA so that I no longer have red alerts on the imports?

For the record: I did not write this code. I have been asked to maintain it, and fix a bug.
It's my professional opinion that all code should be under version control, and I don't want to edit the code directly on the Jenkins web pages but in a IDE so that I have syntax checking, autocomplete, and all the other usual conveniences.

You are allowed to assume that there are only 3 files in the repository: a .groovy file, a .gitattributes and a .gitignore. I do know how to write code in the Groovy language, but I don't know how to set up a Groovy project. As an analogy: I know how to fly a plane, but I don't know how to take off or land.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/918587c9-70dd-489d-83c8-e8b1d2820cf7n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Amedee Van Gasse
I am happy to report that after adding the following jars to my lib folder, I no longer have errors:

jenkins-core-2.263.3.jar          workflow-api-2.41.jar          workflow-cps-2.87.jar          workflow-job-2.40.jar          workflow-step-api-2.23.jar
jenkins-core-2.263.3-javadoc.jar  workflow-api-2.41-javadoc.jar  workflow-cps-2.87-javadoc.jar  workflow-job-2.40-javadoc.jar  workflow-step-api-2.23-javadoc.jar
jenkins-core-2.263.3-sources.jar  workflow-api-2.41-sources.jar  workflow-cps-2.87-sources.jar  workflow-job-2.40-sources.jar  workflow-step-api-2.23-sources.jar

The unfortunate part is that I still have to manually hunt down the correct jars and add them to git, but at least I can finally start with coding!
On Tuesday, February 16, 2021 at 1:21:23 PM UTC+1 Amedee Van Gasse wrote:
Answering my own question for at least the hudson.* and jenkins.* imports:

* download jenkins-core for my Jenkins version from https://repo.jenkins-ci.org/ (in my case: version 2.263.3, so I need https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-core/2.263.3/jenkins-core-2.263.3.jar)
* save the jar in a directory lib
* add the jar as a library to my project

Now, at least for the hudson and jenkins imports, IntelliJ doesn't complain.
I think I'll have to repeat for the Workflow plugin?

Now, I know that this is the really old fashioned way of doing it, from the days of yore from before dependency management.
I'd prefer not to have the lib folder with jars added to git.

What would be a nice dependency management ish way of doing it?


On Tuesday, February 16, 2021 at 1:08:01 PM UTC+1 Amedee Van Gasse wrote:
Following up on my previous question about a System Groovy Script.

I have a .groovy file in a git repo.
I have cloned the git repo to my pc.
I have opened the directory in IntelliJ IDEA.

Now I get a lot of red text. None of the imports are found.
It looks like this:

import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction


How do I configure IntelliJ IDEA so that I no longer have red alerts on the imports?

For the record: I did not write this code. I have been asked to maintain it, and fix a bug.
It's my professional opinion that all code should be under version control, and I don't want to edit the code directly on the Jenkins web pages but in a IDE so that I have syntax checking, autocomplete, and all the other usual conveniences.

You are allowed to assume that there are only 3 files in the repository: a .groovy file, a .gitattributes and a .gitignore. I do know how to write code in the Groovy language, but I don't know how to set up a Groovy project. As an analogy: I know how to fly a plane, but I don't know how to take off or land.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/215cec8c-1d63-42f3-b33e-29ae19646767n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Yannick Lacaute
Hello, maybe you could you use maven to declare the dependencies instead of downloading them manually.
The IDE will download jars and resolve imports automatically, this is what I do when I develop shared library for example.

On Tue, Feb 16, 2021 at 1:47 PM Amedee Van Gasse <[hidden email]> wrote:
I am happy to report that after adding the following jars to my lib folder, I no longer have errors:

jenkins-core-2.263.3.jar          workflow-api-2.41.jar          workflow-cps-2.87.jar          workflow-job-2.40.jar          workflow-step-api-2.23.jar
jenkins-core-2.263.3-javadoc.jar  workflow-api-2.41-javadoc.jar  workflow-cps-2.87-javadoc.jar  workflow-job-2.40-javadoc.jar  workflow-step-api-2.23-javadoc.jar
jenkins-core-2.263.3-sources.jar  workflow-api-2.41-sources.jar  workflow-cps-2.87-sources.jar  workflow-job-2.40-sources.jar  workflow-step-api-2.23-sources.jar

The unfortunate part is that I still have to manually hunt down the correct jars and add them to git, but at least I can finally start with coding!
On Tuesday, February 16, 2021 at 1:21:23 PM UTC+1 Amedee Van Gasse wrote:
Answering my own question for at least the hudson.* and jenkins.* imports:

* download jenkins-core for my Jenkins version from https://repo.jenkins-ci.org/ (in my case: version 2.263.3, so I need https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-core/2.263.3/jenkins-core-2.263.3.jar)
* save the jar in a directory lib
* add the jar as a library to my project

Now, at least for the hudson and jenkins imports, IntelliJ doesn't complain.
I think I'll have to repeat for the Workflow plugin?

Now, I know that this is the really old fashioned way of doing it, from the days of yore from before dependency management.
I'd prefer not to have the lib folder with jars added to git.

What would be a nice dependency management ish way of doing it?


On Tuesday, February 16, 2021 at 1:08:01 PM UTC+1 Amedee Van Gasse wrote:
Following up on my previous question about a System Groovy Script.

I have a .groovy file in a git repo.
I have cloned the git repo to my pc.
I have opened the directory in IntelliJ IDEA.

Now I get a lot of red text. None of the imports are found.
It looks like this:

import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction


How do I configure IntelliJ IDEA so that I no longer have red alerts on the imports?

For the record: I did not write this code. I have been asked to maintain it, and fix a bug.
It's my professional opinion that all code should be under version control, and I don't want to edit the code directly on the Jenkins web pages but in a IDE so that I have syntax checking, autocomplete, and all the other usual conveniences.

You are allowed to assume that there are only 3 files in the repository: a .groovy file, a .gitattributes and a .gitignore. I do know how to write code in the Groovy language, but I don't know how to set up a Groovy project. As an analogy: I know how to fly a plane, but I don't know how to take off or land.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/215cec8c-1d63-42f3-b33e-29ae19646767n%40googlegroups.com.


--
Yannick

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAG1W_AzkUJ49g2_keurOwth-pkgqTkzBV1OahcEmXUwJL5ETWQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: System Groovy Script: hudson.*, jenkins.* and org.jenkinsci.* imports are not found in IntelliJ IDEA

Amedee Van Gasse
Oh? I didn't know that Maven also did Groovy.
You learn something new every day, don't ya?

For now I did something with Gradle. Don't know if it actually works because I have never used Gradle before, and I already had the jars in my lib folder. But anyway, as long as it #worksforme, it's good enough.

Thanks!

On Tuesday, February 16, 2021 at 2:32:05 PM UTC+1 [hidden email] wrote:
Hello, maybe you could you use maven to declare the dependencies instead of downloading them manually.
The IDE will download jars and resolve imports automatically, this is what I do when I develop shared library for example.

On Tue, Feb 16, 2021 at 1:47 PM Amedee Van Gasse <[hidden email]> wrote:
I am happy to report that after adding the following jars to my lib folder, I no longer have errors:

jenkins-core-2.263.3.jar          workflow-api-2.41.jar          workflow-cps-2.87.jar          workflow-job-2.40.jar          workflow-step-api-2.23.jar
jenkins-core-2.263.3-javadoc.jar  workflow-api-2.41-javadoc.jar  workflow-cps-2.87-javadoc.jar  workflow-job-2.40-javadoc.jar  workflow-step-api-2.23-javadoc.jar
jenkins-core-2.263.3-sources.jar  workflow-api-2.41-sources.jar  workflow-cps-2.87-sources.jar  workflow-job-2.40-sources.jar  workflow-step-api-2.23-sources.jar

The unfortunate part is that I still have to manually hunt down the correct jars and add them to git, but at least I can finally start with coding!
On Tuesday, February 16, 2021 at 1:21:23 PM UTC+1 Amedee Van Gasse wrote:
Answering my own question for at least the hudson.* and jenkins.* imports:

* download jenkins-core for my Jenkins version from https://repo.jenkins-ci.org/ (in my case: version 2.263.3, so I need https://repo.jenkins-ci.org/releases/org/jenkins-ci/main/jenkins-core/2.263.3/jenkins-core-2.263.3.jar)
* save the jar in a directory lib
* add the jar as a library to my project

Now, at least for the hudson and jenkins imports, IntelliJ doesn't complain.
I think I'll have to repeat for the Workflow plugin?

Now, I know that this is the really old fashioned way of doing it, from the days of yore from before dependency management.
I'd prefer not to have the lib folder with jars added to git.

What would be a nice dependency management ish way of doing it?


On Tuesday, February 16, 2021 at 1:08:01 PM UTC+1 Amedee Van Gasse wrote:
Following up on my previous question about a System Groovy Script.

I have a .groovy file in a git repo.
I have cloned the git repo to my pc.
I have opened the directory in IntelliJ IDEA.

Now I get a lot of red text. None of the imports are found.
It looks like this:

import hudson.model.*;
import hudson.util.*;
import jenkins.model.*;
import hudson.FilePath.FileCallable;
import hudson.slaves.OfflineCause;
import hudson.node_monitors.*;
import org.jenkinsci.plugins.workflow.job.WorkflowRun
import org.jenkinsci.plugins.workflow.flow.FlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.graph.StepStartNode;
import org.jenkinsci.plugins.workflow.cps.nodes.StepStartNode;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction


How do I configure IntelliJ IDEA so that I no longer have red alerts on the imports?

For the record: I did not write this code. I have been asked to maintain it, and fix a bug.
It's my professional opinion that all code should be under version control, and I don't want to edit the code directly on the Jenkins web pages but in a IDE so that I have syntax checking, autocomplete, and all the other usual conveniences.

You are allowed to assume that there are only 3 files in the repository: a .groovy file, a .gitattributes and a .gitignore. I do know how to write code in the Groovy language, but I don't know how to set up a Groovy project. As an analogy: I know how to fly a plane, but I don't know how to take off or land.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/215cec8c-1d63-42f3-b33e-29ae19646767n%40googlegroups.com.


--
Yannick

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/0f10d5f7-23e6-422d-89a1-c78a01d321d0n%40googlegroups.com.