Not able to see "Invoke ANT" option on Jenkins 2.85 - jenkins

I am using Jenkins version 2.85 and trying to invoke or add ANT plugin. However, I can't see "Invoke ANT" option under Global Tool Configuration.
I have configured ANT and verified the version as follows.
Apache Ant(TM) version 1.10.1 compiled on February 2 2017
Trying the default build file: build.xml
Buildfile: build.xml does not exist!
Build failed
Kindly let me know how can I get "Invoke ANT" option.
Thanks,
Narasimha

You probably need to install Jenkins ANT plugin for that.

Install Ant Plugin by going to Manage Jenkins -> Manage Plugins -> Available Tab and search for Ant and install all the relevant ant plugin.
Configure ant plugin by going to Manage Jenkins -> Global Tool Configuration.
You'll see an option Ant, either install Ant if you don't have on the local system or if you have ant configured on your local system, directly provide the ANT_HOME.

Related

Missing Ant Global Tool Configuration in Jenkins

Why doesn't the Ant Configuration in my Jenkins appear under Global Tool Configuration?
See the image below:
There are only tabs for JDK and Maven.
In the other references I checked, there are others like Git and Ant, etc.
Make sure that the Ant Plugin is installed in your Jenkins instance. Go to Manage Jenkins -> Manage Plugins and search for the plugin there under the Available tab.

install jenkins with java thats in a specifed folder

I want to update jenkins(currently using jdk 6;to upgrade jenkins i need jdk7) but so, many application in my jenkins server use jdk6.So, I cannot update java.So, I want to copy java binary in folder like /home/username/java and I want to make jenkins use /home/username/java while updating.So, the other programs don't get disturbed(Most of them use which java and get the java installation example:maven and some other tools I am not aware of).Is there a config file which can be edited to make jenkins use a java in a specific folder(while installing or updating).
There is a JDK dropdown in "job name" -> Configure in Jenkins web UI. It will list all JDKs available in Jenkins configuration.
You can add new JDKs through Manage Jenkins -> Global Tool Configuration -> JDK.
Here is a visual of where you should configure additional JDKs in Jenkins:

Jenkins Cannot find executable for ANT

I'm using the automatic installation option for Ant but still jenkins complains that it cannot find the executable. Am I missing something? I have given the path to the ant version we use. It has successfully downloaded and unpacked it on the server but it still complains it can't find the executable.
Did you install Ant? Is it in Jenkin's PATH? If not, Jenkins cannot use the default version of Ant.
However, if you go into the Jenkins configuration page, you can install various versions of Ant. For example, you may want to install the latest version of Ant, and Ant 1.5 for that one project that cannot use any version of Ant beyond 1.5:
When you define your project, you can select the version of Ant you want to use. When you select that you want to Invoke Ant as a build step, you are given a drop down menu of what version of Ant you want to use. The first is the Default which is the Ant version found in your PATH. However, if you've gone into Jenkins configuration and downloaded other versions of Ant, you can use one of those instead.
I think is more easy to you install ant manually , or you need check the jenkins log file for detailed errors
Found what I missed. I had to add the name of the directory it unpacks the ant file to in the
"Subdirectory of extracted archive" field. Forgot to mention we are using a fairly old version of ant. (1.7.0).

ant/Jenkins: move doesn't support the "quiet" attribute

My build script executes:
<move todir="gen" overwrite="true" quiet="true">
<fileset dir="gen">
<include name="**/BuildConfig.java.new"/>
</fileset>
<globmapper from="*.java.new" to="*.java"/>
</move>
I get the error:
move doesn't support the "quiet" attribute
I have ant 1.8.4 installed on my iMac. My ant plugin in Jenkins is 1.2. Jenkins ver. 1.505.
I have tried to change the PATH when starting Jenkins, so it includes my command line ant.
However it seems that Jenkins does not support ant 1.8.3? ant 1.8.3 is the version where the "move quiet" was added.
Any thoughts how I can solve this? Is it related to command line ant or plugin ant or my build script?
Thanks!
Assuming that you're running Jenkins on your iMac, go to [http://yourjenkins/configure] and add an Ant installation that points to your Ant 1.8.4 directory. Then, in the Ant build step of your Jenkins job configuration, specify that version of Ant and things should start working.
If your Jenkins server is on a different machine, repeat the instructions but install Ant 1.8.4 on the Jenkins server, or use the "Install automatically" option to install Ant on demand.
I solved it by:
In Jenkins setup, set a tool location for ant
Now in my build job a new selection appeared: Ant Version
My ant on my mac:
ant -v
Apache Ant(TM) version 1.8.4 compiled on May 22 2012

Cannot run program "gradle" in Jenkins

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.

Resources