Develop jenkins groovy script in Eclipse - eclipse

Is it possible to develop a groovy script (pipeline) for Jenkins in Eclipse?
I want to connect to a running Jenkins instance and create / start some jobs. How can i achieve this?

Jenkins does not have strong IDE support in any IDE. However, Eclipse (as well as most major java IDE's) does have a groovy plugin and you can import the core jenkins jars to get some auto-completion. At the very least, the IDE gives you autoformatting, with is of some help. Once you've developed your script, you will have to copy it out to jenkins to test.

To work with Jenkins Pipeline, I have setup Eclipse like this:
Download and extract Jenkins.war Distribution (it's just a zip file with *.war file extension) from jenkins.io, currently version 2.361.1 LTS.
Run the jenkins war file.
2.1. Open a terminal and run java -jar jenkins.war.You will see that Jenkins will ask for the initial configuration and it will provide an initial password.
2.2. Copy the initial password showed in the terminal.
2.3 Open http://localhost:8080 in a WebBrowser and paste the initial password you have copied from the terminal.
2.4. Follow the steps to install the default plugins. All of these files will be saved in $HOME/.jenkins folder.
Install Eclipse Java IDE Version 2022-03 (4.23.0), I chose flavor: "Eclipse IDE for Java Developers"
Install Eclipse Groovy Plugin 4.5.0 (via Help->Marketplace search for groovy)
Create an Eclipse User Library via Window -> Preferences:
Then go to Java -> Build Path -> User Libraries, add new User Library with name "Jenkins Pipeline". Then add the following "External Jars..." to this library.
Uncompress jenkins.war (tar xvf jenkins.war) file and add the following files:
5.1. jenkins/WEB-INF/lib/*.jar
Add these libraries from the plugins directory of jenkins home:
5.2. ~/.jenkins/plugins/workflow-cps-global-lib/WEB-INF/lib/*.jar
If you cannot find this directory it means you are running a new version of Jenkins. In this case, you should use:
~/.jenkins/plugins/pipeline-groovy-lib/WEB-INF/lib/*.jar
5.3. ~/.jenkins/plugins/workflow-cps/WEB-INF/lib/*.jar
5.4. I also add junit to the library because it is often used:
~/.jenkins/plugins/junit/WEB-INF/lib/*.jar
Create your groovy pipeline project:
File -> New -> Project... -> Groovy -> Groovy Project.
Then add the User Library "Jenkins Pipeline" to the Build Path:
Right click the groovy project -> Build Path -> Add Libraries -> User Library
Finally add more libraries from the plugins folder to your project according to your needs

Related

How to install EditorConfig NetBeans Plugin?

I want to install EditorConfig NetBeans Plugin by following instructions on this link: https://github.com/welovecoding/editorconfig-netbeans#readme, but it doesn't help me a lot. At instructions sections, it is written:
mvn clean install
I ran this command on cmd and git, but It didn't work. So where should I run this command? And in which directory should i keep my pluging files?
Regards.
To build plugin from source on Windows you first need to configure few things.
1. Install JDK (Java SE Development Kit).
Get it from http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html. Install with default settings.
2. Download Apache Maven
Get it from https://maven.apache.org/download.cgi. Extract archive content preferably to some short path.
3. Set JAVA_HOME
Go to Control Panel -> All Control Panel Items -> System -> Advanced System Settings ->Environment Variables
Add new user environment variable JAVA_HOME and set it to newly installed JDK.
4. Add Maven bin folder to PATH
Like above edit user PATH variable and add new path for extracted archive like C:\maven\bin.
5. Check if mvn works
In cmd type mvn -v.
Output should look similar to:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: C:\maven\bin\..
Java version: 1.8.0_121, vendor: Oracle Corporation
Java home: C:\Program Files (x86)\Java\jdk1.8.0_121\jre
Default locale: pl_PL, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "x86", family: "dos"
6. Get editorconfig-netbeans repository
Git clone or download zip from https://github.com/welovecoding/editorconfig-netbeans.
7. Build new plugin
Inside editorconfig-netbeans folder run
mvn clean install
This will build plugin and run test. New plugin (.nbm file) will be inside /target folder.
8. Install plugin
In Netbeans go to Tools -> Plugins -> Downloaded. Use Add Plugins... button to add new .nbm file and install it.
OR
You could save yourself all trouble and get build versions from https://github.com/welovecoding/editorconfig-netbeans/releases
Download pre-built release here: https://github.com/welovecoding/editorconfig-netbeans/releases.
Then in netbeans, use the Tools Menu: Tools -> Plugins.
Go to the 'Downloaded' tab, and click on 'AddPlugins...' Navigate to where the release was downloaded, then click the install button.

nodejs configuration using (*.p2f) file in eclipse

I am newbie to nodejs environment. I just started learning about nodejs but I got stuck with environment set up.
When I am trying to set up the environment using *.p2f file which i downloaded from eclipse market place support site for nodejs, I am getting following errors
Help me to sort out the problem
configuration problem using .p2f file in Node Tool Suit
You have got Enide .p2f file, that should be used in Eclipse as File -> Import -> Install -> Install Software Items from File. (All instructions are inside .p2f file, that you can open with text editor. It is just XML file )
Actually, Nodeclipse project download page http://www.nodeclipse.org/updates/ has a lot of options to get started with Node.js and Eclipse.
You can download Enide Studio wit ready to go plugin set.
Or Install Nodeclipse plugin into any Eclipse based IDE.
select what option would work for you.
#Dot_NET Junior please raise an issue on https://github.com/nodeclipse/nodeclipse-1/issues/ if you are still interested in created solution with Node.js and Eclipse

How do you install Groovy and Grails plugins for Eclipse/STS without direct internet access?

I’m using a Windows 7 Enterprise edition 64 bit, the firewall means certain update sites are not directly accessible and my standard user is not a local admin.
How do you install the Groovy and Grails plugins for STS?
Update (July 2012): There is now a preconfigured version of STS availabe which comes with Groovy and Grails, simply install or unzip the package and Groovy, Grails and their plugins are pre-installed and working. This is available on the STS site here (eg Groovy/Grails Tool Suite version 3.0.0.M3 zip file is here
I originally had a number of problems with admin/access rights and the inline STS extensions update site getting blocked by the firewall. I thought installing STS as a local admin would help things but this actually made it worse and caused problems when running STS from a normal user account later. Here are the final steps needed…
User Access Issues:
Create a directory eg c:\devtools
c:\devtools -> a directory where STS can be installed. (Your Windows 7 User must have full read/write access)
Unzipping and all other actions described below should be done as your normal user (this doesn’t require a local admin user) A local admin was only needed to create the devtools directory and grant full read/write access to the standard user.
Download/Firewall Issues:
The following files can be downloaded from a separate computer and moved across so the developer PC doesn’t require direct internet access
Download the STS Windows Zip File http://www.springsource.org/downloads/sts
Eg STS 2.9.0 / Eclipse 3.7.2, Windows 64 Bit zip file http://download.springsource.com/release/STS/2.9.0/dist/e3.7/springsource-tool-suite-2.9.0.RELEASE-e3.7.2-win32-x86_64.zip
Unzip this to your ‘devtools’ directory
Download Groovy STS Plugin http://ci.repository.codehaus.org/greclipse/snapshot/e37/old/
eg Archive v2.6.1 for STS 2.9.0 http://ci.repository.codehaus.org/greclipse/snapshot/e37/old/archive-2.6.1.xx-20120118-1100-e37-M1.zip
Go to STS -> Help -> Install New Software -> Click ‘Add’,
enter a name, eg ‘STS Groovy Update Zip file’, click ‘Archive’ and select the file that you just downloaded
Click ‘Select All’ -> then ‘Next’ -> then ‘Finish’,
Accept the confirmations etc then after it has been installed restart STS
Download Eclipse Update Zip File (which includes the Grails Plugin) (The Groovy Plugin must be installed first) http://www.springsource.org/downloads/sts
Update Site STS 2.9.0 / Eclipse 3.7.2, eg http://download.springsource.com/release/TOOLS/update/2.9.0.RELEASE/e3.7/springsource-tool-suite-2.9.0.RELEASE-e3.7.2-updatesite.zip
Go to STS -> Help -> Install New Software -> Click ‘Add’, enter a name, eg ‘STS Update Zip file’, click ‘Archive’ and select the file that you just downloaded
Select ‘ Core / STS’ ->
Click ‘Extensions / STS’ -> ‘SpringSource Tools Suite Grails Support’ then ‘Next’ -> then ‘Finish’
Accept the confirmations etc then after it has been installed restart STS
I've found using the Dashboard works for me. In STS (I'm using 2.9.1, but it worked in 2.8.1 as well and probably earlier), click Help | Dashboard. Near bottom of that Dashboard, you'll see two tabs [Dashboard] and [Extensions]. Click on Extensions and you get a list of the extensions/plugins that are available. I'm not sure if this works any differently through the firewall.
I have installed STS (v2.9.2) (Eclipse 3.7) from exe (downloaded from www.springsource.org/downloads/sts ) file and followed Chris's response, just changed the address/name like below -
Groovy STS Plugin: http://ci.repository.codehaus.org/greclipse/snapshot/e37/old/archive-2.7.0.xx-20120605-0900-e37-RELEASE.zip Grails Support: http://download.springsource.com/release/TOOLS/update/2.9.2.RELEASE/e3.7/springsource-tool-suite-2.9.2.RELEASE-e3.7.2-updatesite.zip. Though the package explorer is not the same with auto installer, yet it did miracle. Thanks Chris :-)

Compile Groovy files in Eclipse

My java web project includes some Groovy code. But eclipse is not recognizing Groovy files and not generating any classes out of it.
I have installed Groovy plugin in Eclipse. Installed Groovy in my windows machine and setup GROOVY_HOME and include groovyall jar file in my lib folder. But no luck.
Please help.
Have you converted your project into a groovy project? In order for groovy files to be compiled, they must be in a groovy project. Select Project, right-click -> Configure -> Convert to Groovy Project...
This will set up the groovy dependencies correctly. You can remove the groovy-all jar from your lib folder.
You could also use STS, when the dashboard opens up click on the "extensions" tab and click on the Groovy language feature and install it. Then right click on project, -> Spring -> configure groovy nature to use groovy also.
Another option is create a new Groovy project, the upshot is that you can use any java file within a groovy project since they are so well coupled.

Where is mvn.exe when using embedded maven 3 in eclipse indigo?

I'm using the Indigo Release of eclipse. When I check Window -> Preferences, Maven -> Installations, it confirms that it's using the Embedded (3.0.2/...) installation of Maven.
I want to be able to run maven commands from the command line (Windows Powershell), but when I type, e.g.,
PS C:\> mvn
no executable is found. I did a search for "mvn.exe" and found no results.
I suppose I could install a stand-alone version of Maven 3 and add that to my PATH, but I'd prefer to be using the same Maven installation for command line tasks as well as IDE (eclipse) tasks.
So, where is the embedded maven's mvn.exe hiding?
The simple answer is, cause it's embedded in Eclipse so you can't call it from console. If you like to do this you have to install Maven yourself.
There is no mvn.exe at all. The Maven distro comes with batch or shell scripts. Eclipse runs an embedded version which is called through an API.
remember, embedded maven is not configured to work out of eclipse environment (and terminal usage is out of STS usage).
we have to install maven.
and also note, there is no "mvn.exe"
follow the following to setup maven to work from terminal.
maven download link is here
download latest maven from here
extract it where ever you want.
i extracted as below (see the bin,boot,conf,... folders are shown below as in the image):
as this maven download is extracted from zip file (it is not setup), you will have to add this extracted path to "PATH" variable in windows environment.
follow this to set environment path:
now "mvn" command must work.
in my case, i use STS (spring tool suite)
and i had to restart STS for "mvn" to work in terminal in sts.
check it out with eclipse.