JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
Hudson is a continuous integration (CI) tool that is available for Windows and Linux.
Where appropriate, references to the Hudson Continuous Integration website and The Hudson Book are provided.
Note: The Hudson project has been discontinued and archived. This page is provided for users who are already using Hudson and wish to integrate with CodeSonar. If you are not already using Hudson, we recommend using a different CI tool. For example, there is a CodeSonar integration for Jenkins, which is the successor to Hudson.
The Hudson project has been discontinued and archived. If your development group is not currently using Hudson, we recommend using a different CI tool, such as Jenkins (which is the successor to Hudson).
This page is provided for users who are already using Hudson and wish to integrate with CodeSonar.
There are three main steps.
The next step is B. Make sure CodeSonar is ready to analyze your software.
Note that if Hudson is running as a service, its owner will usually be SYSTEM.
| C and C++ projects | For every existing build step that involves C/C++
compilation, edit the build step to incorporate the
CodeSonar build/analysis command (see Build and Analysis
for C/C++ Projects for more information). If the current
build step or steps contain one command that involves C/C++
compilation, this will involve constructing a single codesonar analyze
command. Otherwise there are two possible approaches:
The codesonar analyze command must include either the -foreground option or the wait option (but not both). Note that -foreground cannot be used with -remote analysis-launchd. |
|---|---|
| Java projects | Add a new, final
build step that executes the CodeSonar Java build/analysis
with a suitable cs-java-scan
command (see Build and Analysis for
Java Projects for more information). The codesonar analyze command must include
either the -foreground option or the -wait option (but not both). Note that -foreground cannot be used with -remote analysis-launchd. See Example 3. |
| Mixed Java and C/C++ projects | Combine the approaches for Java-only and C/C++-only projects:
|
These examples all assume the following:
| CodeSonar hub location | alexdesktop:7340 |
|---|---|
| project directory | /myfiles/csonar_projects/projX |
| project name | ProjectX |
Suppose that the Hudson job build step text is:
cd /myfiles/src/projX && make normal
Then replace the build step text with:
cd /myfiles/src/projX && codesonar analyze /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340 make normal
Suppose that the Hudson job build step text is:
cd /myfiles/src/projX rm -f *.o gcc -c A.c gcc -c B.c gcc -c C.c
There are several possible approaches.
| Option 1 | Replace the build step text with:
cd /myfiles/src/projX rm -f *.o codesonar build /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 gcc -c A.c codesonar build /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 gcc -c B.c codesonar build /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 gcc -c C.c codesonar analyze /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 |
|---|---|
| Option 2 | Collect the build step text into a single shell script
/path/to/dir/mybuildscript.sh:
cd /myfiles/src/projX rm -f *.o gcc -c A.c gcc -c B.c gcc -c C.c cd /path/to/dir && codesonar analyze projectX -foreground alexdesktop:7340 sh -xe mybuildscript.sh |
| Option 3 | Collect the build step text into a single batch file
path\to\dir\mybuildbat.bat:
cd \myfiles\src\projX rm -f *.o gcc -c A.c gcc -c B.c gcc -c C.c codesonar analyze projectX -foreground alexdesktop:7340 path\to\dir\mybuildbat.bat |
Suppose that the Hudson job uses Java source files from /myfiles/sources and writes Java build output to /myfiles/buildoutput/classes
Then add a new "Execute shell" build step with the following contents.
codesonar analyze /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340 cs-java-scan -include-artifacts /myfiles/buildoutput/classes -include-sources /myfiles/sources
Suppose that the Hudson job build step text is:
cd /myfiles/src/projX make all
and that the Hudson job uses Java source files from /myfiles/sources and writes Java build output to /myfiles/buildoutput/classes.
Then replace the build step text with:
cd /myfiles/src/projX codesonar build /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340 make all codesonar build /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340 cs-java-scan -include-artifacts /myfiles/buildoutput/classes -include-sources /myfiles/sources codesonar analyze /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340
Suppose the Hudson job build step text is:
cd /myfiles/src/projX rm -f *.o rm -f *.class gcc -c A.c gcc -c B.c javac J.java
and that the Hudson job writes Java build output to /myfiles/buildoutput/classes.
There are several possible approaches.
| Option 1 | Move the build text to a Makefile, shell script, batch file, or similar, then follow the approach illustrated in Example 4. |
|---|---|
| Option 2 | Replace the build step text with:
cd /myfiles/src/projX rm -f *.o rm -f *.class codesonar build /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 gcc -c A.c codesonar build /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 gcc -c B.c javac J.java codesonar build /myfiles/csonar_projects/projX/ProjectX -foreground alexdesktop:7340 cs-java-scan -include-artifacts /myfiles/buildoutput/classes -include-sources J.java codesonar analyze /myfiles/csonar_projects/projX/projectX -foreground alexdesktop:7340 |
To get the most value out of Hudson, you will probably want to take advantage of more of its features (if you are not already doing so).
Some initial suggestions:
We also highly recommend that you read 7 Ways to Optimize Jenkins/Hudson by Kohsuke Kawaguchi, who created Hudson and Jenkins.
To report problems with this documentation, please visit https://support.codesecure.com/.