Skip first mvn install in travis-ci - travis-ci

I'm having troubles building a project with maven on travis-ci because travis automatically runs
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V
which fails because of a timeout:
No output has been received in the last 10 minutes, this potentially
indicates a stalled build or something wrong with the build itself
According to the documentation I should be able to override it defining a custom script in .travis.yml but it does not work, here my configuration:
sudo: false
language:
- java
script: "travis_wait mvn -T4 -pl quickfixj-codegenerator install"
jdk:
- oraclejdk8
env:
- MAVEN_OPTS="-Xms2048m -Xmx=2048m"
branches:
only:
- travis-ci-build
Is there any way to avoid the automatic mvn install or to tweak it ?

This is mentioned in the documentation:
https://docs.travis-ci.com/user/job-lifecycle/#skipping-the-installation-phase
Skip the installation step entirely by adding the following to your .travis.yml:
install: skip
The install step runs before script step, and with Maven you don't usually need the install step, at least I personally haven't ever found it useful — Maven will download dependencies on script step anyway.

I had the same issue. It was solved after some discussion with the Travis CI support. Here is their response:
That maven command is run as part of the install section of your
build, it's the default.
If you want to skip this step, you can override it by adding this to
your .travis.yml file:
install: /bin/true

I have found it useful to have an install: mvn dependency:resolve step that downloads the build dependencies up front, so that the output of the actual build script is kept clean

Related

Jenkins on ec2 not recognizing composer or npm - both are installed

I've installed Jenkins on an Amazon ec2 instance according to the instructions here https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos and when I try to run a job that has an execute shell command step that does "composer install" or "npm install" it isn't recognizing either command. However from the terminal (as ec2-user) I can run both. Is there something I need to do to let Jenkins know where to find these commands?
I just realized I can sudo su jenkins and install composer as that user.
For NPM, this article helped. You need to install the nodejs plugin, restart Jenkins, then in the build environment section of the configuration of your job, choose "Provide Node & npm bin/ folder to PATH".
I was still having problems running ng commands - after installing the ng client as the jenkins user. This post helped - which says to add "npm run" before ng.
I hope this helps someone. Especially since I figured it out moments after offering my bounty!

How to use Prettier on Bitbucket pipeline?

I am trying to use code formatter, Prettier, on a Bitbucket pipeline but all I get is a "prettier command not found".
This is my pipeline configuration:
mage: node:latest
pipelines:
branches:
master:
- step:
caches:
- node
script:
- npm install prettier
- prettier --check
Is it even possible to run it through pipelines or would have to forcefully do it locally?
I will suggest you follow the documentation https://prettier.io/docs/en/install.html
install prettier in your repo
npm install --save-dev --save-exact prettier
"--save-dev" because the production will not need prettier to serve your application
add your rules in .prettierrc.json file in the root of the repo
in the pipeline use
npx prettier --check .
What is that npx thing? npx ships with npm and lets you run locally installed tools. We’ll leave off the npx part for brevity throughout the rest of this file!
Note: If you forget to install Prettier first, npx will temporarily download the latest version. That’s not a good idea when using Prettier, because we change how code is formatted in each release! It’s important to have a locked down version of Prettier in your package.json. And it’s faster, too.
When you have installed prettier in your repo, you can even add pre-commit hooks to modify the staged files before pushing.

How to integrate Jacoco report in Sonarqube

I'm using Jenkins+Jacoco+Sonarqube to test my code. In Jenkins, my mvn command is:
mvn clean install sonar:sonar.
After code build in Jenkins, I am able to see the code coverage in Jenkins.
But I cannot get proper coverage percentage in SonarQube.
This could be a source path issue, maybe you don’t analyze the same sources. Do you have any excluded source files in Jacoco and Jenkins that you didn’t exclude in SonarQube properties, or vice versa?
Your command doesn't include the generation of the reports. Try instead:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install sonar:sonar
Breaking it down:
mvn invoke the build system
clean delete all old build output
org.jacoco:jacoco-maven-plugin:prepare-agent turn on test reporting
install build and install the result in the local Maven repository
sonar:sonar run a SonarQube analysis

Could not parse .travis.yml

I'm trying to create CI pipeline with GitHub, Travis CI and AWS ECS. When I'm push commit to master branch, I'm getting error in travis CI: 'Could not parse .travis.yml'. I can't figure out, where is the problem. Travis dosen't provide more information about error.
There is a code, which I'm using:
.travis.yml
language: csharp
dist: trusty
sudo: required
mono: none
dotnet: 2.0.0
branches:
only:
- master
before_script:
- chmod -R a+x scripts
script:
- ./scripts/dotnet-build.sh
- ./scripts/dotnet-publish.sh
- ./scripts/docker-publish-travis.sh
dotnet-build.sh
dotnet restore
dotnet build
dotnet-publish.sh
dotnet publish ./BookMeMobi2 -c Release -o ./bin/Docker
dotnet-publish-travis.sh
pip install --user awscli
eval $(aws ecr get-login --no-include-email --region eu-central-1)
docker build -t bookmemobi2 .
docker ps
docker tag bookmemobi2:latest 601510060817.dkr.ecr.eu-central-1.amazonaws.com/bookmemobi2:latest
docker push 601510060817.dkr.ecr.eu-central-1.amazonaws.com/bookmemobi2:latest
I don't know where is the problem. Could you help me?
Use yamllint, which you can install, or just copy&paste to a web-based version.
With the example in the question, I get:
(<unknown>): found character that cannot start any token while scanning for the next token at line 7 column 1
There's a tab on line 7. See "https://stackoverflow.com/q/19975954".
I had a similar problem. In my case I was using python to launch a couple of scripts. I placed them one after the other with a hyphen at the beginning, exactly as you. So I searched to found out that I could place all of them in one line with "&" between each script and I got rid of the hyphen.
What I had:
script:
- python test_Math_DC.py
- python test_Math_Moy.py
- python test_Math_Var.py
- python test_Math_SQRT.py
Changed to :
script: python test_Math_DC.py & python test_Math_Moy.py & python test_Math_Var.py & python test_Math_SQRT.py
In your case you could try :
script: ./scripts/dotnet-build.sh & ./scripts/dotnet-publish.sh & ./scripts/docker-publish-travis.sh
or something like this :
script: sh ./scripts/dotnet-build.sh & sh ./scripts/dotnet-publish.sh & sh ./scripts/docker-publish-travis.sh
And see how it works out.
The travis cli tool has a linter
gem install travis
However, it only gives warnings for the example. Also, it currently does not work with all features, for example stages.
$ travis lint
Warnings for .travis.yml:
[x] unexpected key mono, dropping
[x] unexpected key dotnet, dropping

The command "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" failed and exited with 1 during

I have setup my .travis.yml
as:
language: java
script: mvn clean verify
but I get
The command "mvn install -DskipTests=true -Dmaven.javadoc.skip=true -B -V" failed and exited with 1 during
see
https://github.com/WolfgangFahl/w3cValidator/blob/master/.travis.yml
What is wrong with this setup? Why is mvn install executed when I ask for mvn verify?
I had expected this to work based on:
https://stackoverflow.com/a/33283409/1497139
and checking the .travis.yml with http://lint.travis-ci.org/
In general, I'd recommend using install: true and placing the commands for the build under the script element.
language: java
install: true
script:
- mvn install
There is an important difference between install and script: if the former fails, the build errors, if the latter one fails, the build fails. See the docs:
If before_install, install or before_script return a non-zero exit code, the build is errored and stops immediately.
If script returns a non-zero exit code, the build is failed, but continues to run before being marked as failed.
I ended up with this style of yml file:
# this is a java project using maven
language: java
# install
install: mvn install

Resources