4
Git repository:- xyz/repository
Project:- xyz/repository/project/pom.xml

.travis.yml: [kept in /project]
language: java
script: mvn clean install

Travis CI always executes the script in xyz/repository I tried with below

language: java
script: cd project 
        mvn clean install

But it still executes in xyz/repository

Error: The goal you specified requires a project to execute but there is no POM in this directory

Could someone please help?

hermit05
  • 117
  • 12
  • I would recommend to change the structure of your git repo...apart from that you should use `mvn clean package` or `mvn clean verify` but not `mvn clean install`... – khmarbaise Jan 06 '18 at 17:31
  • Hey! It worked. I was having the yml file in wrong format. I have removed the install goal and put the package goal as per your suggestion. Thanks! – hermit05 Jan 07 '18 at 05:04
  • @khmrbaise, what do you mean by changing the structure of the git repo? Do you mean add a pom.xml to the base level (xyz)? – Woodchuck May 06 '18 at 18:21

2 Answers2

5

Got it working.

Corrected the yml format.

language: java
script: 
  - cd project 
  - mvn clean install

The above works.

hermit05
  • 117
  • 12
3

Create a bash script with simple cd commands before maven clean install. Then reference your bash script in .travis

build.sh :

cd git_repo/
mvn clean install

.travis.yml :

script: ./build.sh
hagai
  • 424
  • 1
  • 7
  • 13
  • That's a clean idea. Will do this. Thanks! – hermit05 Jan 06 '18 at 17:00
  • Will ask a follow up question if you don't mind. How can I exclude one particular test from CI build? I tried with: `mvn clean install -Dtest=!*DaoTest` But the above ended up excluding all the tests. – hermit05 Jan 06 '18 at 17:05
  • It's a question for another thread. You can use @Ignore with junit. https://stackoverflow.com/questions/835705/is-there-a-way-to-skip-only-a-single-test-in-maven – hagai Jan 06 '18 at 17:27
  • Did you get "./build.sh: Permission denied" by any chance? If so, what was your workaround? – Woodchuck May 06 '18 at 18:10
  • 1
    Sounds like another issue, just see how to use chmod https://stackoverflow.com/questions/3740152/how-do-i-set-chmod-for-a-folder-and-all-of-its-subfolders-and-files-in-linux-ubu – hagai May 09 '18 at 09:29