how to use Jenkins plugin in pipeline as code - jenkins-pipeline

I have written a Jenkins plugin using Java and deployed the HPI file in my Jenkins instance. The plugin is available for use when i use freestyle job from the Jenkins GUI. When i try to access/use the plugin in the Pipeline as code (.Jenkins file) i am not able to access or use the plugin i deployed. The plugin is not showing up in pipeline script generator as well. Can some one provide the detail of what i need to do so that the plugin i have written can be used in the pipeline script format as well?

Related

How to setup jenkins to run Selenium / Maven / TestNG

I'd like to be able to run by Jenkins a series of test from Selenium. I've see a lot of topic about the subject but it's not clear to me.
Do I need to call maven to run the project or can I directly call Testng ?
Also do I need with Jenkins to call my project using maven or using Ant ?
What is the best practice. Is there specific plugin that I need.
Do I need to call maven to run the project or can I directly call Testng ?
You can call testng through maven or ant. There is no direct runner plugin for Jenkins.
What is the best practice. Is there specific plugin that I need.
You might need the TestNG plugin to show the results inside Jenkins, but it is optional. Best practice is to use maven or ant. You can find a nice ant example here
You can use run TestNG scripts in Jenkins with or without Maven. Maven as a build tool, in my opinion, looks more robust and gives you more flexibility than Ant.
To run pure TestNg script in Jenkins, enter the following in the 'build' section:
D:>java -cp "Pathtolibfolder\lib\*;Pathtobinfolder\bin" org.testng.TestNG testng.xml
Click on Save button.
Note: The actual path of lib and bin folder need to add the in above
command.
After saving the command, Jenkins will build project in predefined
time, and this command will run using TestNG.
The result will be stored in custom report HTML file that can be sent via
email with a small Jenkins configuration

Automatic features provision on Fuse ESB/Servicemix with Maven

Is there any way to provision/deploy features to Fuse ESB/Servicemix automaticaly though Maven, like cargo for Tomcat? Using ant+ssh is not an option.
I'm currently finalizing a client wrapped in a maven plugin that will do just that, but instead of the fusesource approach of using the hot deployment folder I connect directly to the remote karaf console and execute the commands required to (un)install features.
The auto deploy is part of automated regression tests executed by Jenkins through a set of SoapUI test scripts.
Basically I use apache SSHD to connect to karaf (see an example here: https://cwiki.apache.org/KARAF/63-programmatically-connect-to-the-console.html) and some custom code to execute the commands and parse the result.

How to use ANT in Cloudbees

I'm trying to move an existing ANT build script (build.xml) into Cloudbees for CI using Jenkins. I setup the project repository using GitHub. The build pulls the repository into the Cloudbees Workspace successfully, but then fails with this message.
Parsing POMs
ERROR: No such file /scratch/jenkins/workspace/project/pom.xml
Perhaps you need to specify the correct POM file path in the project configuration?
I'm not too familiar with this, but from what I can tell (thanks Google) it's because Cloudbees uses Maven instead of ANT. Is there a way that I can change Jenkins to run the ANT build script instead of using Maven? Or a simple way to execute my ANT scripts from Maven? Any help here would be appreciated!
Thanks
You do not need a Maven POM file if your project is Ant-based.
It sounds like you created a Maven job in Jenkins. Delete it and create a free-style job instead, then (as #thekbb says) click Add build step and select Invoke Ant and configure as needed.
ant support is provided by teh ant plugin, I think you get this automatically when installing jenkins. In your jenkins job, add a build step of type 'Invoke Ant' and provide the target.

Publish JavaDoc on Jenkins with maven

I have maven project that is built by Jenkins-CI.
How to generate and publish JavaDoc on Jenkins?
Make sure Jenkins javadoc plugin is installed.
Go to http://yourjenkinsserver.com/jenkins/pluginManager/installed to see list of intalled plugins.
Plugin page https://wiki.jenkins-ci.org/display/JENKINS/Javadoc+Plugin
Configure Jenkins job:
In Build section, Goals and options line add:
javadoc:javadoc
That's all. No need to change pom.xml
The simplest thing to do is to create a separate task that runs thr javadoc command, and which runs after the compile task. You pass it the input and output directories.
I would run a separate tomcat for your CI website - it's easier.

Jenkins JDepend Plugin reports JAR classes

I am using 1.467 and Jenkins JDepend plugin 1.2.3.
When I build, it generates the JDepend report.
No problem.
THe problem is that I get reports on classes like:
org.apache.commons.fileupload
org.hibernate.ejb
Packages report on classes that I didn't write.
How I configure this so that it JDepend only run on classes that I write?
com.mycompany.myproject
for example.
Thanks.
JDepend Maven Plugin looks quite old and seems to be in beta. It does not support a way to exclude packages/classes. I assume jenkins JDepend Plugin uses the information from this to generate the report.
JDepend itself provides options to include/exclude classes/packages from analysis. JDepend ant task provides support for this as well.
One possibility would be to use jdepend ant task using maven antrun plugin (or directly invoke jdepend using maven exec plugin) to do the analysis and specify the report file to jenkins plugin for reporting.
i got it to work by setting the goal to "jdepend:generate" and setting the Pre-generated JDepend file to "target/jdepend-report.xml"

Resources