SONAR analysis from parent directory - ant

I have a simple question, yet I don't have an answer. Can some one pls help:
What I have is:
ParentDirectory
Child_module1
Child_module2
I'm analyzing using sonar ant.
<property name="sonar.sources" value="/xyz/home/emahaboo/work/abc_project_branch/ParentDirectory"/>
<property name="sonar.binaries" value="/xyz/home/emahaboo/work/abc_project_branch/ParentDirectory"/>
I'm able to connect to the sonar server and get the integration test coverage for 1 module. Like this
<property name="sonar.sources" value="xyz/ParentDirectory/childModule1"/>
<property name="sonar.binaries" value="/xyz/ParentDirectory/childModule1"/>
There are "n" number of modules. I wanted to know how to run the following:
1. Run analysis for more than 1 module. like this
xyz/ParentDirectory/ChildModule1
xyz/ParentDirectory/ChildModule2
2.Run analysis from the ParentDirectory
xyz/ParentDirectory/
Issues I am facing:
For 1: I see SONAR analyses on ChildModule2
For 2: I get this error: Caused by: java.lang.IllegalStateException: Fail to get the canonical path of xyz/ParentDirectory/ / / / / /
Can some one please help?
Really apprecite it

The Sonar documentation describes how multi-module builds are configured in ANT:
Multi-module documentation
It also provides links to two examples:
java-ant-modules-same-structure
java-ant-modules-different-structures

Related

Process leaked file descriptors jenkins ERROR on Jenkins

Can someone help me to solve an issue "process leaked file descriptors jenkins"?
I tried whit BUIL_ID = dontkillme but it doesnt work.
Thx
It would help to know more about what you're trying to run but this question came up as a result of troubleshooting an issue I was having so here's how I resolved it. I am using Windows so if you're using something else it may not work for you.
First of all you need to read and understand the Jenkins documentation on the issue: https://jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors
I had to install Ant first since it was not installed.
https://ant.apache.org/bindownload.cgi
The Jenkins documentation gives you an example Ant script:
<exec executable="cscript.exe">
<env key="ANTRUN_TITLE" value="Title for Window" /> <!-- optional -->
<env key="ANTRUN_OUTPUT" value="output.log" /> <!-- optional -->
<arg value="//NoLogo" />
<arg value="antRunAsync.js" /> <!-- this script -->
<arg value="real executable" />
</exec>
You will change the "real executable" to be the executable you are wanting to run.
See that .js file in the 2nd arg value? You will need to create that. There's a link to this on the Jenkins documentation page too. Grab it here: https://wiki.jenkins.io/download/attachments/1835010/antRunAsync.js?version=1&modificationDate=1184046328000&api=v2
I didn't make any edits to the contents, just pasted it right in and saved it as antRunAsync.js
So now you take your Ant example script I posted above and throw that in a text editor, save as build.xml
From this point you should be able to test on the command line by typing ant and pressing enter. Your application should load in a different window.
If you haven't set up Ant in the Jenkins Global Tool Configuration do so now and point it to your Ant install (might have to uncheck the Install checkbox). In the Jenkins project add a build step Invoke Ant. Set that up how you like according to Ant documentation.
Hope this answer helps someone else who has stumbled across this problem and this question.

Executing jmeter tests only if the previous jmeter test passes

I am running my jmeter tests using Jenkins and maven-jmeter plugin.
My pom.xml is configured as below.
<testFilesIncluded>
<jMeterTestFile>001-Test1.jmx</jMeterTestFile>
<jMeterTestFile>002-Test2.jmx</jMeterTestFile>
<jMeterTestFile>003-Test3.jmx</jMeterTestFile>
<jMeterTestFile>004-Test4.jmx</jMeterTestFile>
<jMeterTestFile>005-Test5.jmx</jMeterTestFile>
</testFilesIncluded>
Also, using performance plugin in jenkins for reporting.
So if my first test (001-Test1.jmx) fails (assertions fail), i do not want to execute the next test (002-Test2.jmx).
How can i accomplish this ?
Thanks for your help in advance.
I'm not sure if that helps,
but if you used TestNG you could make sure a certain number of test methods have completed and succeeded before running more test methods by setting the dependencies in testng.xml
<test name="My suite">
<groups>
<dependencies>
<group name="c" depends-on="a b" />
<group name="z" depends-on="c" />
</dependencies>
</groups>
</test>
Hope you can make some use of it.
Using ant, you can define different Jmeter tests as separate targets and set up dependencies between them. That's exactly what you need. Remember that maven describes the structure of your project, not the logic of its execution (if-then). But ant does. So, try to switch to ant.

ojdeploy - ant task compile application

I am trying to use ojdeploy to compile and build an ADF application through an AntTask.
The ojdeploy task works fine when I specify not to compile the project by adding the line
The ojdeploy task is unable to find several jars required to build the application which I have specified.
I can't find any documentation which describe the use of the ojdeploy to compile applications which makes me think that it does not work.
The ant task I have is below. My thoughts are that the ojdeploy task does not have the jars required to build the project on its classpath. I can't see a way to add these jars to the classpath however.
ojdeploy task:
<target name="deploy" description="Deploy JDeveloper profiles">
<property name="status" value="${env.WORKSPACE}/deploy/ojdeploy-statuslog.xml"/>
<taskdef name="ojdeploy"
classname="oracle.jdeveloper.deploy.ant.OJDeployAntTask"
uri="oraclelib:OJDeployAntTask"
classpathref="classpath"/>
<ora:ojdeploy xmlns:ora="oraclelib:OJDeployAntTask"
executable="${env.oracle.middleware}/jdeveloper/jdev/bin/ojdeploy.exe"
failonerror="true"
ora:buildscript="${env.WORKSPACE}/deploy/ojdeploy-build.xml"
ora:statuslog="C:/Oracle/Middleware/ojdeploy-statuslog.xml">
<ora:deploy>
<ora:parameter name="workspace"
value="${env.WORKSPACE}/JWS.jws"/>
<ora:parameter name="profile"
value="*"/>
<!--<ora:parameter name="nocompile" value="true"/>-->
<ora:parameter name="outputfile"
value="${env.WORKSPACE}/deploy/${deployment.profile.name}"/>
</ora:deploy>
</ora:ojdeploy>
</target>
Resolved.
ojdeploy uses the jws and jpr files to find the libraries required. The jpr file was missing several JDeveloper/ADF libraries which JDeveloper is able to resolve.
However for ojdeploy to work ALL the libraries and dependencies are required to be in the jws/jpr file accordingly using the libraries/classpath and dependencies options.

Could not create task or type: getProjectData from Ant

I am trying to run an Ant task from within IBM RSA IDE using Ant build ...
I get the following error message:
BUILD FAILED
build.xml:21: Could
not create task or type of type: getProjectData.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'getProjectData'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use
Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath
Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
Here's the Ant buildfile:
<!-- Get property locationName. -->
<target name="config">
<echo message="${ear.project.name}" />
<getProjectData projectName="${ear.project.name}" />
</target>
I am not quite sure what the problem is here because the error message seems not helpful. Any suggestions?
I believe getProjectData is an IBM extension to ant. Like you, I had a similar error, but I was able to get it working after ensuring the Run in the same JRE as the workspace option was enabled (which you can find by right-clicking the build file, run-as, Ant Build..., and selecting the option on the JRE tab).
I discovered the solution on the IBM info center:
The Run in the same JRE as the workspace option enables the classpath
of the workbench to access the additional Ant tasks that perform
operations that are specific to the workbench, such as projectImport,
projectBuild, workspaceBuild, ejbDeploy, or earExport. If your Ant
build script uses any Ant tasks that perform workbench operations,
verify that you selected the Run in the same JRE as the workspace
option; otherwise you might get the following error message in the
Console view:
Problem: failed to create task or type <Ant task> Cause:
The name is undefined.
The build file I used looked like this:
<?xml version="1.0"?>
<project name="Test" default="config" basedir=".">
<target name="config">
<getProjectData Basedir="${basedir}" />
<echo message="getProjectData: projectName=${projectName}
nature=${natureName}
workspace=${workspaceName}
basedir=${basedir}" />
</target>
</project>
And output:
Buildfile: C:\DATA\java\workspace\test-java\build.xml
config:
[getProjectData] Setting projectName=test-java
[getProjectData] Retrieved following Project Data :
[getProjectData] workspaceName=C:\DATA\java\workspace
[getProjectData] natureName=Java
[echo] getProjectData: projectName=test-java
nature=Java
workspace=C:\DATA\java\workspace
basedir=C:\DATA\java\workspace\test-java
BUILD SUCCESSFUL
Total time: 78 milliseconds

checking latest version in version control

i am currently writing an ANT script which will include some intelligence to check for things. I am using SnapshotCM from True Blue Software as my version control and using CruiseControl as a framework for my nightly build.
Basically, I will need to always check for the latest version found in my version control and execute commands. In this case here is an example:
<project name="nightly_build" default="main" basedir="checkout">
<target name="init">
<property file="initial.properties"/>
</target>
<target name="main" depends="init">
<!-- need some code to set variable -->
<!-- need some code to increment variable -->
<!-- need some code here to check for the latest version -->
<exec executable="C:/Program Files/True Blue Software/SnapshotCM/wco.exe">
<arg line='-f -R "C:/Work/7.10.000_Tip/7.10.000_Tip_GUI_TEST/"'/>
</exec>
</target>
</project>
In the code above, I will load the "initial.properties" file.
The algorithm should be as follow:
load the initial properties file
get the build_number
increment build_number by 1 (let this new variable be X)
if X is found, increament X by 1 (if not found jump to 6.)
if X is found, repeat 4 (until X cannot be found)
else use the build number inside the <arg line ='-f -R "C:/..../7.10.100.X..../"'/>
The initial.properties file is as follow:
Major_Version=7
Minor_Version=10
Project_Number=100
Build_Number=036
Product_Version=${Major_Version}.${Minor_Version}.${Project_Number}.${Build_Number}
can anyone guide me on that?
Ant is not a programming language. It's a dependency matrix language.
That means you don't specify execution order in Ant. Ant will calculate the order it needs to run the targets. It also means Ant doesn't have the ability to do loops, or even change the value of a property once it is set.
There are a few packages that build upon Ant. The old standby is the Antcontrib. Antcontrib has the concept of variables which are like mutable properties. It also has various looping structures. However, I'm not sure if the <foreach> or <for> tasks will do what you want...
Searching sequentially for the next build number is something you can do in a shell script. In fact, I highly recommend this.
I use Ant for builds only and keep my CM functions outside of my build.xml file. Instead, I rely on my build system to do everything that's not related to the build itself. This includes checking out the code, saving the artifacts, and compiling unit tests. This way, if I change the way I use my continuous build system or my version control system, I don't have to modify my build.xml files.

Resources