Jenkins failing build when not finding ".part" files - java

I've created a Jenkins job for maven releases. When doing "release:perform" the build fails with messages of this kind:
Caused by: java.io.FileNotFoundException:
/home/jenkins/.m2/repository/org/sonatype/sisu/inject/guice-bean/1.4.2/guice-bean-1.4.2.pom.part (No such file or directory)
The file changes sometimes, but the kind of error is always the same.
When performing the release manually (aka on my own machine) the error does not happen.
My job run the following commands:
mvn clean install
mvn release:clean release:prepare -e -B
mvn -X release:perform -e -Dusername='username' -Dpassword='password' -Darguments="-Dmaven.javadoc.skip=true"
I believe it's related to space on disk or something similar to that. Is there any kind of config to fix it?
ps: the slaves are not running on containers yet
Thanks in advance

Related

I need maven to give more detailed logs

we have an angular+java app which gets built with maven and I have been trying to decrease our gitlab pipeline duration
i was wondering if there is a way to have better logs
i have tried -e & -X switches in the command (mvn $MAVEN_CLI_OPTS clean install -Dmaven.test.skip=true -P prod)
im also open to suggestions about more detailed angular build log

How to run maven command in AWS Device Farm

I am trying to run my java mobile project in device farm using maven.
When I run this command on my local machine in the right directory it works:
mvn test -D "cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps --tags #InstallApp"
I put this command on the yaml file in the aws device farm but it doesn't work.
This is the error I get:
[DeviceFarm] echo "Start Appium TestNG test"
Start Appium TestNG test
[DeviceFarm] mvn test -D
"cucumber.options="src/test/java/cucumber/features" --glue
cucumber.steps
--tags #InstallApp"
[INFO] Scanning for projects...
[INFO] BUILD FAILURE
[ERROR] The goal you specified requires a project to execute but there
is
no POM in this directory (/tmp/scratchncneoU.scratch/test-
packageO6o8s7).
Please verify you invoked Maven from the correct directory. -> [Help 1]
How can I run this maven command in device farm? Where is the pom located there?
Thanks
After typing this command in the yaml file:
[DeviceFarm] java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="classpath:features" --glue cucumber.steps --tags #InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
I get an error of: Couldn't find the testng.xml in the jar file although I have this in my pom:
<directory>${project.basedir}/src/test/java/cucumber</directory>
</testResource>
</testResources>
What can it be?
The mvn command fails because your deployment package doesn't contain the whole project. From the sound of things with the current deployment package you should be able to do what you want with this command:
- java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH -D"cucumber.options="src/test/java/cucumber/features" --glue cucumber.steps
--tags #InstallApp" org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10
Otherwise, if you want to use maven you'll need to zip up the whole project and include it's pom.xml. So for example using the sample cucumber java tests
git clone https://github.com/aws-samples/aws-device-farm-appium-cucumber-tests-for-sample-app.git
zip -r deployment_package.zip aws-device-farm-appium-cucumber-tests-for-sample-app
Then you should be able to use maven in the testspec.yml file. For example, I could run the following command for the sample: mvn clean test after going to the project dir and then to get the results I had to export the target directory.
test:
commands:
# Your test package is downloaded in $DEVICEFARM_TEST_PACKAGE_PATH so we first change directory to that path.
- echo "Navigate to test package directory"
- cd $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app
- mvn clean test
...
artifacts:
# By default, Device Farm will collect your artifacts from following directories
- $DEVICEFARM_TEST_PACKAGE_PATH/aws-device-farm-appium-cucumber-tests-for-sample-app/target
- $DEVICEFARM_LOG_DIR
However, you'll need to upload the zip file as an APPIUM_NODE test type to avoid the test package parser there.
HTH
-James

Maven - Check a local dependency on Windows

I'm must verify a maven local dependency into a python script. I succeed to do it on linux using this command (from this thread).
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://~/.m2/repository
My problem is that I'm working with a team using Windows, Linux and Mac, under Windows I'm unable to execute this command, the repo path is the one from mvn configuration maybe the problem is coming from the way I'm calling it as parameter.
mvn dependency:get -Dartifact=g:a:v -o -DrepoUrl=file://C:\Users\user\.m2\repository
Is someone already use this command on Windows and have any hints to solve this problem ?
Thank you .
Finally I reached a solution.
I'm not sure to understand but on windows firstly I must run :
mvn dependency:get
before running :
mvn dependency:get -Dartifact=g:a:v -o
I think the problem about 'dependency plugin' is solved by the first command.

Unable to run Maven Commands on Docker as Non-root

I am building my project on docker (using docker-maven) and need to execute it as non-root.
From the official documentation, it seems that running maven as non-root is supported (https://github.com/carlossg/docker-maven#running-as-non-root).
So I run the following:
sudo docker run -v "$PWD":/var/maven -w /var/maven -ti -u 1000 -e MAVEN_CONFIG=/var/maven maven mvn package -Duser.home=/var/maven
where $PWD is my project root directory.
However, I always get permission related issue such as
Error while storing the mojo status: /var/maven/mymodule/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst (Permission denied)
or unable to delete some files if I run mvn clean package instead.
How do I run the command as non-root properly?

Maven not found while using Gitlab-ci-multi-runner

I've been trying to set up GitLab-CI to build Maven Java projects in Raspbian, but whenever It tries to run the build script it fails because it can't find Maven. I used this guide to install the runner.
Build trace:
Running with gitlab-ci-multi-runner 1.10.4 (b32125f)
WARNING: image is not supported by selected executor and shell
Using Shell executor...
Running on raspberrypi...
Cloning repository...
Cloning into '/home/gitlab-runner/builds/f09314a8/0/RBian/TestProject'...
Checking out 54d2e140 as master...
Skipping Git submodules setup
$ mvn clean package
bash: line 22: mvn: command not found
ERROR: Build failed: exit status 1
.gitlab-ci.yml
image: maven:3-jdk-8
build:
script: "mvn clean package"
artifacts:
name: "TestProject"
paths:
- "target/*.jar"
Does anyone know what causes this?
EDIT: Modifying /etc/default to add $MAVEN_HOME/bin to $PATH did the trick.
Try adding MAVEN_HOME path into config.toml environment field.
environment = ["MAVEN_HOME=/path/to/maven"]

Categories

Resources