I am trying to learn Jenkins and Git. I have created a simple Freestyle project which takes a simple source code below from git and and prints Hello, World. The Hello_java file commits to git fine.
public class Hello {
public static void main (String [] args) {
system.out.ptintIn ("Hello, World");
}
}
The console output gives error below
Error: Could not find or lead main class Hello
what I am doing wrong?
This error comes when there is a problem with the .class file. To run this program, you need the .class file that is created when you compile the .java file. Have you compiled it (or gotten Jenkins to compile it for you)? If not, you have to do:
javac Hello.java
Then, you should be able to run:
java Hello
And everything should work.
Welcome to SO!
See this tutorial .
Steps:
code that compiles locally correctly committed in a git repo in github/bitbucket/own server etc
add a jenkins file in the repo based on the tutorial
add git repo credentials ( app password) in jenkins secrets (manage jenkins area )
create a jenkins job in pipeline mode and add your repo and select the credential and the path to your jenkins file
build
As later steps you want to see what to do with the deliverables obtained (.jar .war files etc) .
You can pack them and download from jenkins (easiest), store them in a repo (like artifactory/nexus) or build a container image with the server running that jar and push it to a docker repository (private dockerhub, gcp, aws etc) .
Note: jenkins server should have docker installed in order to get maximum flexibility from it.
Hi my Import job with Jenkins is failing with below error . I'm trying to import .xml from Slave machine. I can able to see .xml file in slave location but still getting the error for file not found . when we run the test from Master then it can able to search the xml . so can anyone help with this ?
ERROR: File path is a directory or the file doesn't exist
ERROR: Step ‘Xray: Results Import Task’ aborted due to exception:
java.io.IOException: java.io.IOException: File path is a directory or the
file doesn't exist
at
Looks like it is not able to findthe xml file. when i try to import same file using Curl command it is working . can any one help to solve it ?
I'm converting my Nunit xml to nunit2 for my HTML reporting . I tried to import nunit 2 converted xml manually and works fine but from Jenkins keep on getting error .
If you are able to add plugins to your Jenkins server, there is a plugin specifically to do this, but you won't find it on the Jenkins plugin manager, follow the steps here to install and configure;
Xray for JIRA Jenkins Plugin
In short;
Download this xray-for-jira-connector.hpi
Go to the Update Center of Jenkins ("Manage Jenkins" > "Manage Plugins")
Select the advanced tab
On the Upload Plugin section, click upload and select the file xray-for-jira-connector.hpi file.
Next you need to add your JIRA server configuration to Jenkins (Manage Jenkins > Configure System > Xray for JIRA configuration).
Once you have done the above, you should now be able to add a build step that can export Cucumber feature files from any Cucumber tests you have set up within Xray, and, a post-build action for importing test results files including an NUnit XML file.
All of the info here is described in more detail in the first link i provided, as well as additional information on how to setup the build step and post build action. Hope this helps.
I am trying to deploy a downloaded war file using the deploy-artifact goal in Wildfly. I would like to do this from the command line.
I am getting the following error
deploy-artifact must specify the artifactId
I have added the wildfly details to the pom.xml and tried to run following command:
mvn wildfly:deploy-artifact -DtargetDir=${project.build.directory}
-DartifactId=artifact-name
I think this goal is not intended to be used from the command line since it requires the artifact to be a dependency of the project. The goal documentation doesn't state any user property for the artifactId or groupId parameters so these are only settable in the configuration section of the plugin. I'm also struggling with our test setup and deployment of artifacts from our maven repo. But if you have already downloaded the artifact why don't you just use the cli to deploy it?
Im trying to setup jenkins in my company and Ive got some problems.
Im using this commands to build the project:
SET MSBuild="C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe"
SET BUILDS=C:\Program Files (x86)\Jenkins\jobs\xxx\builds\
SET OUTPUT_PATH="%BUILDS%%BUILD_NUMBER%"
SET RSVARS="C:\Program Files (x86)\Embarcadero\RAD Studio\10.0\bin\rsvars.bat"
CALL %RSVARS%
SET PATH=%PATH%;D:\komponenty\DXE3\ADSI
%MSBuild% xxx.dproj /t:Build /p:Config=Debug;Platform=Win32;DCC_ExeOutput=%OUTPUT_PATH% /maxcpucount:4
It works fine when i type this in cmd but. I gave administrive privileges to jenkins service. When I try to build project with jenkins i receive error like this:
F1026: File not found: 'ADSI.dcu
this is a component for Delphi and i have this component on second partition. Jenkins has access for many components on this partition but not for this one.
The difference between the two will be your current directory.
Jenkins will start you off in a specific working folder for the job (possibly C:\Users\<User-ID>\.jenkins\jobs\<Job-Name>\workspace).
Add the following to your Jenkins commands to see where you're doing the build from:
echo Current Folder: %cd%
A simple "solution" would be to just add a command in Jenkins to change directory to the same folder you're in when you test from the command-line.
However, I suggest you rather do the following:
Ensure Jenkins gets the latest source from your source repository into its working folder. (There are various plugins depending on what particular tool you use.)
Ensure you cd (change directory) to the correct folder within the workspace folder.
I've installed the Gradle plugin for Jenkins. When I try to build the project I get the following error:
[workspace] $ gradle clean -b build/build.gradle
FATAL: command execution failed
java.io.IOException: Cannot run program "gradle" (in directory "/Users/Shared/Jenkins/Home/jobs/test/workspace"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
at hudson.Proc$LocalProc.<init>(Proc.java:244)
at hudson.Proc$LocalProc.<init>(Proc.java:216)
at hudson.Launcher$LocalLauncher.launch(Launcher.java:707)
at hudson.Launcher$ProcStarter.start(Launcher.java:338)
at hudson.Launcher$ProcStarter.join(Launcher.java:345)
at hudson.plugins.gradle.Gradle.performTask(Gradle.java:201)
at hudson.plugins.gradle.Gradle.perform(Gradle.java:97)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:695)
at hudson.model.Build$RunnerImpl.build(Build.java:178)
at hudson.model.Build$RunnerImpl.doRun(Build.java:139)
at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:465)
at hudson.model.Run.run(Run.java:1404)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:238)
Caused by: java.io.IOException: error=2, No such file or directory
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
at java.lang.ProcessImpl.start(ProcessImpl.java:91)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:453)
... 16 more
Build step 'Invoke Gradle script' changed build result to FAILURE
Build step 'Invoke Gradle script' marked build as failure
Finished: FAILURE
Running the task $ gradle clean -b build/build.gradle from the command line works as expected.
I had the same issue and found that the problem for me was the gradle version in the project configuration. It was set to Default and when I set it to the gradle version I was pointing to in the plugin configuration in the Manage Jenkins > Configuration Options, It found gradle and worked properly.
This is a difficult issue to debug and I hope this saves someone else some time.
Solution Mastering_the_Object pointed out worked form me too, just to clarify steps there:
just installing Gradle plugin in Jenkins is not enough, you must also go to:
Jenkins->Manage Jenkins->Configure Jenkins->Configure system.
Under "Gradle Installations" type in name (it appears as version in project configuration), check "Install automatically" and select version. Then you can select that "Gradle version" in project configuration.
I was getting this error using the Gradle wrapper, was able to fix my broken build as follows:
Go to Manage Jenkins -> Global Tool Configuration -> Gradle -> Add Gradle, give it a name
Go to Jenkins -> (your job) -> Configure -> Build, choose "Invoke Gradle" and change the Gradle version from (Default) to the named version
When running Gradle on a CI machine such as Jenkins, it's most convenient to use the Gradle Wrapper.
On your development machine, stand in your root project directory and run
gradle wrapper
Then, check in the resulting files into your source control system. After that, you don't have to install anything on your Jenkins server if you need to change Gradle versions. Just configure your Jenkins job like this:
Quoting from the Gradle User Guide:
By distributing the wrapper with your project, anyone can work with it
without needing to install Gradle beforehand. Even better, users of
the build are guaranteed to use the version of Gradle that the build
was designed to work with. Of course, this is also great for
continuous integration servers (i.e. servers that regularly build your
project) as it requires no configuration on the server.
The jenkins can not find the gradle executable. I have never made gradle wrapper to work. Please follow the following steps:
Download gradle ( http://gradle.org/downloads),
unpack it to, e.g., /usr/local/lib/gradle ,
open /etc/profile and add the following two lines:
export GRADLE_HOME=/usr/local/lib/gradle
export PATH=$PATH:$GRADLE_HOME/bin
It works for my jenkins installation.
ps. I answer this old question, because it is a common issue when setting up gradle with jenkins. I have spent some time trying to make the gradle wrapper work without success before.
Used both #Skarab & a number of other solutions here to get it to work.
Download gradle ( http://gradle.org/downloads),
unpack it to, e.g., /usr/local/lib/gradle ,
open /etc/profile and add the following two lines:
export GRADLE_HOME=/usr/local/lib/gradle
export PATH=$PATH:$GRADLE_HOME/bin
Then under Manage Jenkins > Configure system > Gradle, defined GRADLE_HOME and gave that gradle installation a name
Then, {this could be a bug} for the project, change gradle version from Default to the one I defined above
As others have noted, this is because Jenkins can't find the gradle executable.
None of the published solutions worked for me, but I was able to fix the problem by adding the gradle bin dir to the path set in the .bashrc for the build account on the build slave. Modifying the .profile failed, and setting PATH in the jenkins node configuration also failed.
Some posts will suggest setting the gradle path in the tools menu, but no gradle entry was available there either (perhaps due to regressions / design changes in the gradle plugin?).
In any case, the best test I found (short of running the build again and watching for failure) was to run env over ssh:
ssh <host> env
and check the PATH variable defined that way; if gradle isn't in that path, you probably won't be able to run it from jenkins.