I'm running TeamCity 7 on Ubuntu 12, and I'm trying to deploy a war file to a tomcat server on machine with IP x using Ant.
The thing is - this worked on a different machine with TeamCity 7, and the only thing I've changed is the machine (moved to Ubuntu running on KVM), and the TC version (upgrade).
I've set ANT_HOME to the correct location, and I see the TC is using it in the build log:
... -Dant.home=/usr/share/ant ...
I've added the following jars to my ANT_HOME/lib:
catalina-ant, tomcat-coyote, tomcat-juli, tomcat-util
The build is running on an agent which has the default Ant settings
My ant file looks like this:
<target name="deploy.to.server">
<property name="port" value="${tomcat.port}"/>
<property name="tomcat.manager" value="manager/text"/>
<property name="url" value="http://${tomcat.server}:${port}/${tomcat.manager}"/>
<property name="path" value="/${server.name}"/>
<echo message="Deploying application to ${url}"/>
<antcall target="undeploy.from.tomcat"/>
<sleep seconds="3"/>
<antcall target="deploy.to.tomcat"/>
</target>
<taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/>
<taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
<target name="deploy.to.tomcat" description="Install web application">
<deploy url="${url}" username="${username}" password="${password}"
path="${path}" war="${work.dir}/${path}.war"/>
</target>
<target name="undeploy.from.tomcat" description="Remove web application">
<undeploy url="${url}" username="${username}" password="${password}"
path="${path}"/>
</target>
I've got this in the TC log:
[Step 1/2] Starting: /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java -Dagent.home.dir=/home/system/dev/TeamCity/buildDeployAgent -Dagent.name=Deploy Agent -Dagent.ownPort=9091 -Dagent.work.dir=/home/system/dev/TeamCity/buildDeployAgent/work -Dant.home=/usr/share/ant -Dbuild.number=131 -Dbuild.vcs.number.Nutrino_Monitor_sources=588 -Dbuild.vcs.number.Nutrino_build_scripts=590 -Dfile.encoding=ANSI_X3.4-1968 -Dfile.separator=/ -Djava.io.tmpdir=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp -Dos.arch=amd64 -Dos.name=Linux -Dos.version=3.5.0-19-generic -Dpath.separator=: -Dteamcity.agent.cpuBenchmark=684 -Dteamcity.agent.dotnet.agent_url=http://localhost:9091/RPC2 -Dteamcity.agent.dotnet.build_id=45574 -Dteamcity.auth.password=mlTjdmhOxwfxuM6vGfcQPsKg81q29rFU -Dteamcity.auth.userId=TeamCityBuildId=45574 -Dteamcity.build.changedFiles.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/changedFiles7524737972530602224.txt -Dteamcity.build.checkoutDir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -Dteamcity.build.id=45574 -Dteamcity.build.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.build3049879068391711216.properties -Dteamcity.build.tempDir=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp -Dteamcity.build.workingDir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -Dteamcity.buildConfName=Deploy to Integration -Dteamcity.buildType.id=bt38 -Dteamcity.configuration.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.config301718488736388101.properties -Dteamcity.projectName=Nutrition Builds -Dteamcity.runner.properties.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/teamcity.runner1078243400245029410.properties -Dteamcity.runtime.props.file=/home/system/dev/TeamCity/buildDeployAgent/temp/agentTmp/ant7992360137092769527runtime -Dteamcity.tests.recentlyFailedTests.file=/home/system/dev/TeamCity/buildDeployAgent/temp/buildTmp/testsToRunFirst5600043147441131768.txt -Dteamcity.version=7.1.2 (build 24170) -Dtomcat.server=integration -Duser.country=US -Duser.home=/home/system -Duser.language=en -Duser.name=system -Duser.timezone=Asia/Jerusalem -Dwork.dir=/home/system/dev/TeamCity/Builds/DeployNutritionServer -classpath /usr/share/java/ant-launcher-1.8.2.jar org.apache.tools.ant.launch.Launcher -lib /home/system/dev/TeamCity/buildDeployAgent/plugins/antPlugin/ant-runtime.jar:/home/system/dev/TeamCity/buildDeployAgent/lib/runtime-util.jar -listener jetbrains.buildServer.agent.ant.AgentBuildListener -buildfile /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml deploy.nutrino.server
[15:06:21][Step 1/2] in directory: /home/system/dev/TeamCity/Builds/DeployNutritionServer
[15:06:21][Step 1/2] taskdef
[15:06:21]
[taskdef] taskdef class org.apache.catalina.ant.DeployTask cannot be found
using the classloader AntClassLoader[]
[15:06:21]
[Step 1/2] The following error occurred while executing this line:
/home/system/dev/TeamCity/Builds/DeployNutritionServer/build/tomcat.tasks.xml:9: taskdef class org.apache.catalina.ant.DeployTask cannot be found
using the classloader AntClassLoader[]
[15:06:21][Step 1/2] Process exited with code 1
[15:06:21][Step 1/2] Ant output
[15:06:21][Ant output] Buildfile: /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml
[15:06:21][Ant output]
[15:06:21][Ant output] BUILD FAILED
[15:06:21][Ant output] /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/deploy.xml:8: The following error occurred while executing this line:
[15:06:21][Ant output] /home/system/dev/TeamCity/Builds/DeployNutritionServer/build/tomcat.tasks.xml:9: taskdef class org.apache.catalina.ant.DeployTask cannot be found
[15:06:21][Ant output] using the classloader AntClassLoader[]
[15:06:21][Ant output]
[15:06:21][Ant output] Total time: 0 seconds
[15:06:22][Step 1/2] Step Deploy (Ant) failed
Now, this is extremely weird, as when I run this from the command line it works perfectly:
ant -buildfile deploy.xml -Dtomcat.server= ...
There is no apparent difference between the two - running it from the CL and through the TC agent should both be running Ant from ANT_HOME (usr/share/ant), and loading the libraries in $ANT_HOME/lib.
Any help would be appreciated.
:)
Thanks!
Just answering the question,
Thanks to #timomeinen - adding the catalina-ant.jar to $ANT_HOME/lib did the job.
That means it is not seeing the lib catalina-ant.jar
You can add:
classname="org.apache.catalina.ant.DeployTask"
classpath="C:\Programming\Tomcat\Instances\8080\lib\catalina-ant.jar"
It will solve this reference problem, but I guess you will face similar problems in the future with other libraries, so in the long term you will still need solve the reference problem.
Related
I have the following in my Phing build file:
<target name="fixModifiedTime">
<echo msg="Fixing file modified time" />
<exec executable="python" >
<arg value="c:\scm\scripts\git-restore-mtime.py" />
<arg value="-v" />
</exec>
</target>
This is causing the following error in my Jenkins output:
[exec] Executing command: python c:\scm\scripts\git-restore-mtime.py -v 2>&1
[exec] 'python' is not recognized as an internal or external command,
[exec] operable program or batch file.
I am able to execute the same command from the Jenkins workspace directory and it works perfectly. The Python directory is added to my environment variables and the script has the right permissions.
I have also tried adding the script to my repository and running it from within the build environment but have the same error.
Any thoughts please?
I suggest the following:
Try creating Windows batch build step in your Jenkins and put the command in it. See if it runs
It's obvious your Jenkins environment is not the same is your console. See what's missing in Jenkins
Add the python home and path in the Jenkins configuration
I hope this helps
build.xml
<?xml version="1.0"?>
<project default="main" basedir=".">
<echo message="pulling in property files" />
<property file="axis_bujava.properties" />
<echo message="calling the RPM Build Ant" />
<target name="main">
<rpm specfile="example.spec" topdir="${basedir}" command="-bs" />
</target>
</project>
example.spec
Summary: xxx
Name: cdplayer
Version: 1.0
Release: 1
Copyright: xxx
Group: Applications/Sound
Source: xxx.tgz
URL: http://xxx.html
Distribution: xxxx
Vendor:xxx.
Packager: xxx
%description
xxxx
%build
make
%install
make install
output:
Buildfile: /home/user1/workspace/antdemo/build.xml
[echo] pulling in property files
[echo] calling the RPM Build Ant
main:
[rpm] Building the RPM based on the example.spec file
[rpm] -bs: unknown option
[rpm] 'rpm' failed with exit code 1
BUILD SUCCESSFUL
Total time: 848 milliseconds
I had this issue too. In my case the OS did not have the 'rpmbuild' command installed, so the ant task was calling 'rpm' instead as Aaron suggested.
While I'm not sure what "-bs" option is, you might try changing it to "-bb", which is the default. My own builds, plus a few I've seen, usually use -bb (http://richardfriedman.blogspot.com/2007/02/rpm-java-and-frustration.html)
Also see:
http://ant.apache.org/manual/Tasks/rpm.html
I'm try to run a MonkeyTalk script for my iOS app from command line. The script is successfully running in the MonkeyTalkIDE and get executed on the Simulator.
I have build.xml and Monkey-tal.jar files in the same directory of test.mt
The build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="TEST3" xmlns:monkeytalk="antlib:com.gorillalogic.monkeytalk.ant">
<target name="myScript">
<monkeytalk:run agent="iOS" script="test.mt" />
</target>
</project>
I'm running the command:
ant -lib monkeytalk-ant.jar test.mt
and I get the error message:
MacBook-Pro-2948:TEST3 Developer$ ant -lib monkeytalk-ant.jar test.mt
Buildfile: /Users/Developer/Downloads/monkeytalk 2/MonkeyTalkIDE/MonkeyTalkIDE.app/Contents/MacOS/workspace/TEST3/build.xml
BUILD FAILED
Target "test.mt" does not exist in the project "TEST3".
Total time: 0 seconds
Any Idea?
I found the error in the way I was launching the script.
ant -lib monkeytalk-ant.jar myScript
I've just started with Jenkins and I'm just trying to use it to execute phpunit tests.
My steps are: create the file build.xml as here says:
<project name="mbp2" default="build">
<target name="clean">
<delete dir="${basedir}/build"/>
</target>
<target name="prepare">
<mkdir dir="${basedir}/build/logs"/>
</target>
<target name="phpunit">
<exec dir="${basedir}" executable="phpunit">
<arg line="-c app --log-junit ${basedir}/build/logs/phpunit.xml src/MyFirm/FrontendBundle/Tests" />
</exec>
</target>
<target name="build" depends="clean,prepare,phpunit"/>
</project>
So, I executed ant and I got this:
javier#javier-mbp:~/programacion/mbp/myfirm$ ant Buildfile:
/home/javier/programacion/mbp/myfirm/build.xml
clean: [delete] Deleting directory
/home/javier/programacion/mbp/myfirm/build
prepare:
[mkdir] Created dir: /home/javier/programacion/mbp/myfirm/build/logs
phpunit:
[exec] PHPUnit 3.6.4 by Sebastian Bergmann.
[exec]
[exec] Configuration read from /home/javier/programacion/mbp/myfirm/app/phpunit.xml
[exec]
[exec] ...............
[exec]
[exec] Time: 6 seconds, Memory: 157.50Mb
[exec]
OK (15 tests, 18 assertions)
build:
BUILD SUCCESSFUL Total time: 6 seconds
Then I created a new job in Jenkins choosing as git repository as below:
file:///home/javier/programacion/mbp/myfirm/
Finally I built the project, so I expected to see the same output as when I executed ant without Jenkins, but nothing about that..
In the "Console Output" section showed as below:
Started by user anonymous Checkout:workspace /
/var/lib/jenkins/jobs/mbp2/workspace -
hudson.remoting.LocalChannel#76996f0c Using strategy: Default Last
Built Revision: Revision 9aafeea09cdb23317f2426f8209c75341565c070
(origin/HEAD, origin/master) Checkout:workspace /
/var/lib/jenkins/jobs/mbp2/workspace -
hudson.remoting.LocalChannel#76996f0c Fetching changes from 1 remote
Git repository Fetching upstream changes from
file:///home/javier/programacion/mbp/myfirm Seen branch in repository
origin/HEAD Seen branch in repository origin/master Commencing build of Revision 9aafeea09cdb23317f2426f8209c75341565c070
(origin/HEAD, origin/master) Checking out Revision
9aafeea09cdb23317f2426f8209c75341565c070 (origin/HEAD, origin/master)
Warning : There are multiple branch changesets here Finished: SUCCESS
Javier
You need to add an Ant build step. Jenkins doesn't do anything you don't tell it to.
Ant configuration in Jenkins:
Run Jenkins and browse it
Click the link of your project/job name --> Click Configure link at the left
Click "Add build step" combo and select "Invoke Ant" from combo
Fill up necessary fields for Ant configuration and save it
OR, You can execute ant.bat in Windows as below instead of "Invoke Ant":
Run Jenkins and browse it
Click the link of your project/job name --> Click Configure link at the left
Click "Add build step" combo and select "Execute Windows batch command" from combo
Write the proper command (In my case it was: C:\apache-ant-1.8.4\bin\ant.bat) and save it
i am not very familar with taskdef and classname... i am having trouble running an ant script from another ant script:
2011-05-25 15:50:26,040 [Thread-23] WARN ScriptRunner - BUILD FAILED
2011-05-25 15:50:26,040 [Thread-23] WARN ScriptRunner - C:\Work\6.70_Extensions\NightlyBuild\nightly_build.xml:31: The following error occurred while executing this line:
2011-05-25 15:50:26,040 [Thread-23] WARN ScriptRunner - C:\Work\6.70_Extensions\NightlyBuild\Master Build.xml:6: taskdef class com.ANT_Tasks.CFileEdit cannot be found
where line 6 is:
<taskdef mame="CFileEdit" classname="com.ANT_Tasks.CFileEdit" />
my root directory is C:\Work\6.70_Extensions\NightlyBuild and i have a folder C:\Work\6.70_Extensions\NightlyBuild\com\ANT_Tasks and i have a CFileEdit.java in that folder. Anybody knows what is wrong?
Edit:
I do not wish to change the structure of my ANT script, therefore what is the next step here?
i Complied my CFileEdit.java file into CFileEdit.class
I converted CFileEdit.class into CFileEdit.jar
i put this CFileEdit.jar into C:\apache-ant-1.8.2\lib where this is my ant directory?
please tell me if i am doing it right or wrong, i am having issues with this currently
You must compile the .java into a .class and use the class for classpath for the taskdef
Compile CFileEdit.java
Define taskdef as follows -
<taskdef name="CFileEdit" classname="com.ANT_Tasks.CFileEdit">
<classpath>
<!-- refer to the compiled class here along with others as necessary to execute the task -->
</classpath>
</taskdef>