Install gradle on Centos - jenkins

I'm trying to install gradle for building android app with the help of Jenkins. But I'm not able to find the link to download gradle for Centos. I tried to use binaries from https://gradle.org/downloads/, but when I unzipped I got gradle.bat file inside bin directory which tells me that this is for Windows.
Is there a place where I can download gradle for using in Jenkins?

... but when I unzipped I got gradle.bat file inside bin directory which tells me that this is for Windows.
It also contains a file called gradle, which is a shell script.
Your download is also suitable for running on any Linux or UNIX platform .... including CentOS.

Please add the GRADLE_HOME path to the PATH variable by using following steps:
echo $PATH
Copy the echoed paths and add the GRADLE_HOME path e.g.: /opt/gradle/bin to the PATH variable using a colon (:) using command: export PATH = echoed paths:GRADLE_HOME path
Now, you can use the command gradle from any path and it should work.

Related

How can i transfer all installed plugins to another jenkins?

I want to install same plugins in to my local Jenkins which are already installed in other Jenkins.
Want to avoid installing all the 50-60 odds plugin manually
The official Jenkins documentation on installing plugins gives two ways of installing plugins:
Via the web interface
Save the downloaded *.hpi/*.jpi file into the $JENKINS_HOME/plugins directory.
So my answer to your question would be: copy the $JENKINS_HOME/plugins directory from server A to server B.
Don't forget to restart Jenkins afterwards!
There's another way, that's ideal if you're using Jenkins inside a docker container, first you need to extract a list of installed plugins by running curl against your jenkins domain in terminal:
export JENKINS_URL=http://<jenkins_domain>
curl -sSL "$JENKINS_URL/pluginManager/api/xml?depth=1&xpath=/*/*/shortName|/*/*/version&wrapper=plugins" | perl -pe 's/.*?<shortName>([\w-]+).*?<version>([^<]+)()(<\/\w+>)+/\1 \2\n/g'|sed 's/ /:/'
this you return you a list of installed plugins formatted like this:
aws-credentials:1.15
aws-beanstalk-publisher-plugin:1.6.0
aws-java-sdk:1.10.45.2
Then you can run this script against the list saved in a txt file to install all the exported plugins or add it to the end of your Dockerfile like this:
# copy script to container's bin
ADD ./plugin.sh /usr/local/bin/plugins.sh
# copy plugins list to inside the container
COPY plugins.txt /plugins.txt
# runs it
RUN /usr/local/bin/plugins.sh /plugins.txt
Just remember export your JENKINS_HOME variable before doing this.

Installation issue with Ant 1.9.4

I have got a problem with the Ant installation version 1.9.4...
I've downloaded the Ant apache-ant-1.9.4-src.zip from apache official website and extracted the zip to C:\Development\apache-ant-1.9.4
I've added the below in environment variable
ANT_HOME : C:\Development\apache-ant-1.9.4
JAVA_HOME : C:\Program Files\Java\jdk1.7.0_07
PATH : %PATH%;%JAVA_HOME%\bin;%ANT_HOME%\bin;
When I ran the "ant" cmd from command prompt, I got the below issue
C:>ant
ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
C:\>echo %ANT_HOME%
C:\Development\apache-ant-1.9.4
Moreover, Bin folder is not found in downloaded .zip package.
Please anyone let me know, what i did wrong here?
You have downloaded the source of Apache Ant. You need to download the binary package. It should be something like apache-ant-1.9.4.zip.
The alternative is of course to compile the binary on your machine.

Ant Command not Found

I am using Windows 8.1 and I have installed Apache Ant and put it in my Program Files directory, but when I try:
I get:
Is there a reason why this is happening?
You need to update your PATH variable to add the path of Ant. Instructions for how to edit your PATH are here. Alternatively, you can type the full path of ant in the command.

Jenkins how to rename war file

I have deployed a war file in a remote machine using Jenkins. Now I want to rename the war file through jenkins before it extracts the work folder? How can this be done? I tried post deployment action -> execute shell and mv file.war to new-file.war but it returns an error saying : mv: cannot stat `file.war': No such file or directory.
Suppose there was something wrong with my path it would not even have gone to remote location. but for me, after scp' ing it to remote location thru jenkins, and when i try to do a mv, it fails.. What could the reason be??
Adding additional Step of Execute shell during Add build Step or Add post-build action stage, normal renaming shell command mv can be used to rename artifacts.
Note: Make sure use the correct path(Relative to project/workspace root)
Your mv command is probably executed in another directory than the one you are expecting.
To know the directory your script is running in without reading the jenkins / plugin documentation add
echo "pwd of script is: " `pwd`
to your shell script and inspect the output of the jenkins build - that way you can be sure about the directory the script is run in.

Installing Ant on Cygwin

I'm having some trouble figuring out how to install Ant on Cygwin. I want to use Ant to build Nutch. I've looked through a bunch of tutorials but I can't find anything that is low level enough for me to understand. I need something like...
Download ant, put it here
Open Cygwin
type "export ANT_HOME=..."
...
Can anyone help me out here?
Assuming you have a JDK already installed, you can do this:
$ export ANT_HOME=/cygdrive/c/apache-ant-1.7.1
which assumes you've unzipped Ant into C:\apache-ant-1.7.1. Then:
$ export PATH=$ANT_HOME/bin:$PATH
$ ant -version
Apache Ant version 1.7.1 compiled on June 27 2008
In Windows, add the path to your ant /bin directory to the Path system variable. This can easily be done by right clicking on Computer > Properties > Advanced System Settings > Environment Variables, click on Path in the System Variables, click on Edit and add ; followed by the path to your ant bin directory to the end of the Variable value.
Start or restart Cygwin.
Type ant -version The version should be displayed.
Here's a step-by-step guide:
simply download and unzip ANT binaries say into c:\apache-ant-1.8.1
download and unzip NUTCH sources say into: c:\apache-nutch-1.2
open the command prompt and run the following:
cd c:\apache-nutch-1.2
c:\apache-ant-1.8.1\bin\ant
the same would work from the Bash shell, just use Cygwin-style paths:
cd /cygdrive/c/apache-nutch-1.2
./cygdrive/c/apache-ant-1.8.1/bin/ant
That's it, you will find a new directory build containing the output.
For convenience, you might want to add the Ant bin directory to the PATH environment variable so that you don't have to give the full path each time, but that's optional.
BTW I just did those exact steps, and all went fine.
Finally, follow this tutorial to get started.

Resources