Running a java code that generates a csv file as Jenkins job - java

I have some doubts about this, first I want to run my java code in a Jenkins pipeline, and my java needs to get 2 folders as arguments from the Jenkins running environment (linux) and then, my java code will do certain comparisons and generate a csv file.
how to run the java code in my Jenkins job? is it simply to get my cloned java code and run mvn clean compile? and how I can send the arguments from jenkins running environment to the java code? and finally how can I let my csv file appear on my Jenkins job dashboard?

Related

How to time Java program execution using Intellij Idea?

In Intellij IDEA it is possible to create run configurations. When I run a Java program and it completes execution then Intellij IDEA console shows something like this at the end
Process finished with exit code 0/1
We have a unix command time which can be used for timing something. If I want to time a java command execution via command line then I can do something like
time java -version
We have a option of adding external tools in Intellij's run configuration. By default it has make for compiling configured
Now I was thinking that I can possibly add the timing part to my run configurations. But the problem is that the external tools run before the actual execution.
I tried and added external tool time but it gave an error that no arguments were given.
Is it possible to wrap the java command's execution into the time like the example given above via Intellij's run configurations? Finally I want to time the java command's execution without changing the code itself. I am open to solutions other than linux time subject to they can be used with IDEA's run configurations.

How can I run gradle startscript created using installDist task from a batch file in windows OS?

I have Executed the gradle installDist task for my project. After that two start scripts were created one for running in unix like system and another for windows.
I am able to successfully execute the script created for unix systems. But when I tried to run the windows .bat file in my windows system. It is giving below error in command line.
Even if I am trying to run the batch file directly from cmd. It is giving the below error
The input line is too long.
The syntax of the command is incorrect.

testing hbase with jvmti agent

I want to test hbase using its test cases. I downloaded the project from this link and followed the instruction to test the project, which is simply running the command line
mvn test
There is no problem up to here. What I want to do is to run test cases with jvmti agent. The agent works perfectly fine, I tried it on several java files. Normally, I call my agent to test a java file using
java -agentpath:/path/to/agent/agent.so javaProgram
In this case, the project use maven and I am not good at pom files. I tried to use
alias java="java -agentpath:/path/to/agent/agent.so "
However it did not wok. How can I test hbase with my agent?
You can pass JVM arguments to maven by using the MAVEN_OPTS environment variable:
export MAVEN_OPTS=-agentpath:/path/to/agent.so
A more generic solution is to use JAVA_TOOL_OPTIONS environment variable.
On linux: export JAVA_TOOL_OPTIONS=-agentpath:/path/to/agent.so and then run mvn

Running a JAVA program as a scheduled task

I am trying to run a simple JAVA program once per day on a Windows 7 machine.
My code runs fine inside NetBeans. If I do a clean and build it suggests this:
C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
This does not work from the DOS prompt of course because of the space between program and files so I do this:
C:\Program Files\Java\jdk1.7.0/bin/java -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar" -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
This works from the DOS prompt.
I now create a task in Windows Scheduler to run:
C:\Program Files\Java\jdk1.7.0/bin/java
with arguments:
-jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
When I then run it, all I see is a DOS box flashing up for a second. I expect the code to take about 30 secs to run. The code should persist data to a database and no updates happen.
The code also uses java.util.logging so I should see log entries and I don't.
I strongly suspect that I am not running the JAVA command properly or that there's a bad classpath issue that it present when running via Scheduler that isn't there when running from the DOS prompt.
Help would be appreciated. If you've seen this before and can sort it that would be great. If you can tell me how to get a meaningful error trace from Scheduler than that would also be really helpful.
Thanks!
I Think that you could create a simple batch script that will launch your program in this way :
#echo off
REM Eventually change directory to the program directory
cd C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\
REM run the program
"C:\Program Files\Java\jdk1.7.0\bin\java.exe" -jar "C:\Users\User1\Documents\NetBeansProjects\Facebook\dist\Facebook.jar"
Copy it into the notepad and save as java_script.cmd and then schedule this script instead of the program directly.
I solved it after changing all fonts' references to "SansSerif"
I was using Jasper Reports inside Java to create a PDF file. It was working fine when I double click the batch file or Scheduler with Windows Server 2003 but not working with the Scheduler of 2008.
I tried many different things nothing worked so I though Could it be that Windows Server 2008 is blocking the access?.
Now is working perfect. So, if you are having problems check the references to anything you are using.
The scheduler will run under a different user unless you specify what user to run as. If it isn't running as your user then it won't be able to write to your directories.
The real problem to the original question is a java installation issue on Microsoft systems. Java jre installs into Program Files\java. The executable (java.exe) is only installed in that java\bin directory. Running from the command line, the os looks in the proper location for the java.exe. Running from other MS tools (such as VBA Excel or in this case TaskScheduler), it does not!
You can see that TaskScheduler is looking in the wrong place by viewing the tasks history in the TaskScheduler tool. Double click on some of the history events and one will list the action and return code. The action will show that the TaskScheduler is trying to run
"C:\Windows\system32\java.EXE"
So, copy java.exe from the java\bin directory into the place where the scheduler is looking, and now it will work.
Or update your task and provide the full path to java.exe.
You can also update the environment system path to look for java in the java\bin directory, but that has to apply to all users and sometimes this is faulty as well.

Code run by Hudson can't find executable on the command line

I'm setting up my first job in Hudson, and I'm running into some problems. The job monitors two repositories, one containing our DB setup files, the other a bit of code that validates and tests the DB setup files.
Part of the code that runs will throw the validated setup files at PostgreSQL, using the psql command line tool, using Runtime.exec(). This code works perfectly on my machine, but when Hudson executes it (different machine) I get the following error:
java.io.IOException: Cannot run program "psql": CreateProcess error=2, The system cannot find the file specified
psql.exe is on the path, and I can execute it by typing the whole thing at the command line, from the same place Hudson is executing the code. The file that's meant to be passed into psql exists.
Any ideas?
I find that you need to have the programme in the path when you launch hudson or the slave. Despite having the ability to set the path in hudson it doesn't seem to work. You could also put the full path in the command, which is really a good idea from a security perspective anyway.

Categories

Resources