Saturday, July 01, 2017

Using Travis CI for Java Projects

When using Travis CI for automated testing / continuous integration of Java projects created with the NetBeans IDE you have to do the following:
  • On NetBeans, Project/Properties/Sources make Source/Binary Format equal to JDK7. If you use JDK8, Travis CI ant will fail.
  • You must have at least one JUnit test.
  • You have to copy Junit and Hamcrest jars to project directory and add them under Libraries in NetBeans. If you leave them under Test Libraries, Travis CI won't be able to find them.
  • Commit changes to GitHub.
  • Add .travis.yml file to your github project root with the line language: java
  • Go to Travis CI and sign in with your GitHub account. 
  • Click on your Travis CI profile picture / Accounts. Your open source GitHub projects will be listed.
  • Enable your project for CI by clicking the button to its left.
  • Click on the project to go to build page which kicks off build.
  • If you have done everything correctly, you should see a success message at the end of the build page.
  • To add the build banner on top of build page, click on the banner, select Markdown and copy the link. 
  • On your GitHub page, edit, paste the link and commit. 
You can see the build results for my snake project here.

No comments: