How to query Jenkins using java - java

I am programming using java to fetch few information from Jenkins url. I am trying to get information on nodes, projects created etc. All these are get commands. On browsing about it, I reached following link:
http://javadoc.jenkins.io/
I tried using import statement "import hudson.cli.GetNodeCommand;". But it is throwing me error : The import hudson.cli.GetNodeCommand cannot be resolved.
I have imported jars from my JEnkins url ( https://jenkins.example.com/jnlpJars/jenkins-cli.jar). How do I resolve this? I downloaded this jar from github also and that also has same structure as in the screen shot below. There is no GetNodeCommand class inside 'hudson.cli' package. How do I fetch information about nodes?

The class hudson.cli.GetNodeCommand is part of Jenkins core, and not part of the CLI client JAR. See the developer documentation for pointers to building Jenkins itself, if you want to do something with these classes.
If you want to execute GetNodeCommand, you can do so by running the CLI client with the get-node command, e.g.: java -jar jenkins-cli.jar get-node node-name.
A list of all CLI commands available in a given Jenkins installation can be found at https://<jenkins-host>/cli/.
If you want to fetch information not available via the provided CLI commands, the standard way to do so is the Script Console, which enables you to write Groovy to access the Jenkins APIs. This functionality is also exposed through the CLI via the groovy command.

Related

Pre-commit hook for Java Project

is it possible to set pre-commit hook for java & pom based project? I came across blog https://dwmkerr.com/conventional-commits-and-semantic-versioning-for-java/ and able setup commit-msg and he mentioned the command "git config core.hooksPath .githooks" it will work but each developer needs to manually run the command. is there any other way to make automated process?
it will work but each developer needs to manually run the command
That is the problem with client-side hooks: there is always an "activation" to be set by the user.
I know only of one "semi-automatic" way to setup such hooks: using a template directory which can be referenced by a git clone.
Then you would get a repository with addition hooks already in place.

Java SDK HyperLedger Fabric

I am new using the HyperLedger Fabric Java SDK. I have been using the fabcar example as a starting point. I would like to hook up the application to a rest API, where users can submit a transaction to the blockchain but I am having a hard time finding a good resource for this. the example I am following is here: https://github.com/IBM/blockchain-application-using-fabric-java-sdk. From this example, I am simply building the application and then copying the jar file into various classes to invoke the chain and query the chain ,etc. I am a little confused by this approach. Is this the standard for using HyperLedger fabric, all done from the command line like this, and are the logs that are outputted the actual blockchain? Are there any other resources out there that can help me with this concept?
I also experience like you. Before you start to learn how to code Fabric Java SDK, you need to understand all of the components and processes of Hyperledger Fabric. Then, you download the Fabric Java SDK from here. Please read the read.me carefully. After you created the Maven project and imported the latest Fabric Java SDK, then you import the sample project files from this folder. I recommend you to test the project file name End2endIT.java first.
For your info, you need to run the script to create the container in Docker before you run End2endIT.java. The script files are in this folder. When you enter that folder you need to run the script in the command line with .\fabric.sh start to create the container in Docker. There have various commands using in different situations. Please read fabric.sh file carefully.

How to run Scuba project from Eclipse

I try to use Scuba project.I downloaded source with SVN checkout and imported it into Eclipse .Also i imported scuba_smartcards project. Everything is perfect but i have one problem.When i try to run scuba project like java application,have this error message:
Selection does not contains main type
I don't know is a correct to run this source like java application or not.By the way i created my own java class and i want to use scuba's source in main method
Ho i can solve my problem?
thanks everyone
P.s i also found source in github
https://github.com/credentials/scuba
I'm using scuba_sc_j2se
SCUBA is a framework, basically it is a library with active components. Libraries are not standalone applications so they will not contain a main method of their own. You cannot just run it, you need to write or copy an application that uses the framework through the API presented by SCUBA.
One of these applications is the jMRTD application from which SCUBA originated.

Is there a way to run java code when executing "Maven Deploy"?

I have been given the task of developing code that generates an email when a user deploys new code to our servers. I already have the code to generate the email. However Im trying to run this code when we add new code to our servers. We currently deploy new code to our servers using the MAVEN Deploy command in Eclipse. I was wondering if there is a way to run a java main method or something along those lines when a user selects Maven Deploy in Eclipse?
Not sure of your actual use case or if this is the best approach, but you can run java programs using the maven exec plugin. See here for more details: http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html

How to display changes in web browser when Building a RESTful Web Service using Spring?

I am following this tutorial:
https://spring.io/guides/gs/rest-service/
After completing the tutorial I run everything in my web browser on my local host and everything seems to work.However when I make changes in the java code (I made errors on purpose) I can still run everything in the web browser. What do I need to do in order for it to change due to my code changes? I guess I should mention that I am using eclipse and have installed maven as a plugin.
You are changing the source code, but not the compiled files. Your service is using the created "gs-rest-service-0.1.0.jar" file. This is not affected by your code changes.
Jump into the tutorial again where it says:
"Build an executable JAR"
This will rebuild your jar file. Afterwards you will have to restart your service like you did in the chapter "Run the service".
Instead of using maven as a plugin a choose to install it in order to use the command prompt.

Categories

Resources