Jenkins job not using installed maven - maven

I'm having an issue with running a test suite through Jenkins and I can't figure out why it's failing.
My job is set up with maven and according to others, maven is set up on the jenkins server (I don't have permission to check myself). The job is set to run on a specific node using labels (can't check the settings on the labels myself either).
This is the error I get when I run (more or less).
Running as SYSTEM
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
[EnvInject] - Loading node environment variables.
Building remotely on SELECTEDNODE in workspace E:...
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
using credential ABCD
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
...
...
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE"
ERROR: Maven Home null doesnt exist
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
This message keeps repeating
Installer "Extract *.zip/*.tar.gz" cannot be used to install "mvn.3.5.2" on the node "SELECTEDNODE" even though I have this version of maven installed on the selected node (I do not know if this version is on the Jenkins server, just that a maven version is on the server. I am assuming it is the correct version as I mentioned it needed to be this version and have not heard otherwise). Is this what is causing the issue?

There are usually 2 ways to get maven installed for you build. One is on the node server itself and define that maven path in the jenkins node configuration and the other way is to have the maven automatically installed from internet which appears to be the case in your case..when you have multiple maven defined you need to specifically select the maven for your job.

Related

How to build gradle projects completely offline?

Environment:
Linux + JDK 11 + Gradle 5.0
I have several gradle projects which must build from sources without Internet connection/ For example this one git clone --depth 1 --branch 3.0.0 https://github.com/bobbylight/RSyntaxTextArea.git for that first of all I built this project online then copy ~/.gradle to $PROJECT_DIR/grdl , next I want to test this build offine. I perform gradle --stop , clear whole ~/.gradle directory then turn off Internet and run following script:
cp -r ./grdl/* ~/.gradle
cd RSyntaxTextArea
gradle --offline clean build
And everything builds good until I move these files to a different Linux+JDK11+Gradle 5.0 offline machine. When I run same script there I have following errors:
./build.sh
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':RSyntaxTextArea'.
> Could not resolve all artifacts for configuration ':RSyntaxTextArea:classpath'.
> Could not download coveralls-gradle-plugin.jar (org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2): No cached version available for offline mode
> Could not download httpmime.jar (org.apache.httpcomponents:httpmime:4.3): No cached version available for offline mode
> Could not download org.eclipse.jgit.jar (org.eclipse.jgit:org.eclipse.jgit:3.6.0.201412230720-r): No cached version available for offline mode
> Could not download http-builder.jar (org.codehaus.groovy.modules.http-builder:http-builder:0.7.1): No cached version available for offline mode
> Could not download httpclient.jar (org.apache.httpcomponents:httpclient:4.3): No cached version available for offline mode
> Could not download jsch.jar (com.jcraft:jsch:0.1.50): No cached version available for offline mode
> Could not download JavaEWAH.jar (com.googlecode.javaewah:JavaEWAH:0.7.9): No cached version available for offline mode
> Could not download json-lib-jdk15.jar (net.sf.json-lib:json-lib:2.3): No cached version available for offline mode
> Could not download nekohtml.jar (net.sourceforge.nekohtml:nekohtml:1.9.16): No cached version available for offline mode
> Could not download xml-resolver.jar (xml-resolver:xml-resolver:1.2): No cached version available for offline mode
> Could not download httpcore.jar (org.apache.httpcomponents:httpcore:4.3): No cached version available for offline mode
> Could not download commons-beanutils.jar (commons-beanutils:commons-beanutils:1.8.0): No cached version available for offline mode
> Could not download commons-logging.jar (commons-logging:commons-logging:1.1.3): No cached version available for offline mode
> Could not download commons-codec.jar (commons-codec:commons-codec:1.6): No cached version available for offline mode
> Could not download commons-collections.jar (commons-collections:commons-collections:3.2.1): No cached version available for offline mode
> Could not download ezmorph.jar (net.sf.ezmorph:ezmorph:1.0.6): No cached version available for offline mode
> Could not download commons-lang.jar (commons-lang:commons-lang:2.4): No cached version available for offline mode
> Could not download xercesImpl.jar (xerces:xercesImpl:2.9.1): No cached version available for offline mode
> Could not download xml-apis.jar (xml-apis:xml-apis:1.3.04): No cached version available for offline mode
I have four of five gradle projects with similar problem. Surprisingly, one went offline fine on both machines, this one - git clone --depth 1 --branch 0.27 https://github.com/JFormDesigner/FlatLaf.git . I think that I don't understand gradle cache properly. Could you help me to build gradle projects without Internet? It could be any version of Gradle but I tied to Linux + JDK 11.
I think you are hitting this issue: https://github.com/gradle/gradle/issues/1338
That is, cache items are non relocatable. Copying the whole ~/.gradle folder may not be enough, especially if ~ resolves to a different path than in the original machine (i.e. different user). The full path needs to be exactly the same (with Gradle 5.0).
The issue suggests however that version 6.1 makes the cache relocatable, so perhaps you'll have more luck with a recent version (7.2 is the latest at this point in time).
EDIT: The release notes and these docs confirm that the cache can be copied across deployments as of version 6.1.1.
One solution that worked for me is to copy the $'username'/.gradle/caches/modules-2/files-2.1 folder
This contains all the libraries that gradle has cached and could be reused.
I think this was not possible with gradle versons < gradle 6.1.
After copying the files-2.1 folder you can sync the gradle project with the offline mode toggled on intellij/eclipse.
If it still does not work copy the entire caches folder.

No agent found in pool Hosted which satisfies the specified demands: svn maven

Using VSTS, and following this step by step guide, I still get this error.
Am using the hosted pool, and have verified it has maven
What could be missing?
Thanks in advance!
That's actually the svn capability which is missing on the hosted agent. You might have to add a user capability and add a task to run a non-installed version of it and set the path on the current machine.
The other solution would be to install your build machine with all the tools you need

Add maven capability to Team Services build agent

What's the correct way to setup maven on a Team Services Default build agent?
What I have done so far:
I have downloaded the agent on a virtual machine
I have manually installed java and maven on that machine (C:\Java\jdk1.8.0_101 resp C:\Java\maven\apache-maven-3.3.9)
I have added a few environment variables (maven, MAVEN_HOME, M2_HOME)
after that I install the agent using the powershel script .\config.cmd
The agent gets succesfully registered in my visualstudio.com environment, but the maven capability does not get picked up:
After reading several other posts, I manually added the "maven" capability to the agent:
After all this I can start a build that requires maven. But unfortunately the build fails:
How do I get maven to work properly on my default build agent? I cannot find a solution in the MS documentation.
To answer my own question. The mistake that I made was that I created the environment variables as user variables instead of system variables. To sum things up, here's what's needed:
download the agent on a virtual machine
installed java and maven on that machine
add SYSTEM environment variables M2_HOME and JAVA_HOME
install the agent using the powershel script .\config.cmd
Download the agent on a virtual machine
Install java and maven on that machine add SYSTEM environment variables M2_HOME and JAVA_HOME
Run 'path' in command prompt and ensure that the maven installation directory is listed.
Ensure the maven is installed in 'C:\Program Files\Maven'.
Install the agent using the powershel script .\config.cmd.
Restart server or Update agent from Devops Portal.
In my case I have installed in C drive on root and getting error.

Jenkins corrupted, need to know which files I need

I am having issues with Jenkins that I am unable to resolve, and all the solutions I've found online I've used in the past, but are not helping.
I am on windows 2008r2, utilizing svn, jenkins version 1.407.
Initially the service failed, and was not resolved with past methods. In the past I have successfully troubleshoot Jenkins by killing hung processes, restoring the war file, ect.
I have attempted a new install with bringing over the files in the jobs folder. The end result was a partially functioning Jenkins would attempt a build it would report no change and not update.
What I'm trying to determine is a list of files/folders beyond the jobs folder that I need to move to the new install. The initial install predates me and was Hudson. The folder has a number of obviously obsolete files and folders (both a jenkins.war and a hudson.war)
Go to Jenkins home folder and collect:
all ./*.xml files in - these are configuration files for plugins and jenkins itself
users/* in case you have security enabled
subversion-credentials/** and secrets/** for any kind of keys provided in jenkins to access svn or other resources
plugins/*.*pi folder for all plugins - you don't need to have the unpacked folders
jobs/*/config.xml - to retrieve all job configurations; jobs/*/nextBuildNumber if you care to continue build numbers
plugins may create additional folders which you may want to use
with that you should recreate Jenkins as it was. Pay especially attention to config.xml file in root folder - this holds main jenkins configuration. If your issue reproduces on new system most likely a plugin is cause for problems - in that case review log files most likely you will find out which plugin causes trouble.
You didn't indicate if you tried new setup with same version of Jenkins or newer one; if you are using newest version it may be that ssh key handling / svn authentication for each job needs to be updated as somewhen in last few months authentication / security handling changed. Best is to look into Jenkins release log.
I'm using Jenkins 1.55x on CentOS installed as RPM; given that it is a webapp I assume Windows 1.4x setup is similar.

Make Jenkins behave as compile-only tool and then handle all resulting artifacts on primary Jenkins interface

It might be the case here some of things I have in my mind and in this subject has already been discussed here, but I really would be very thankfull to have step-by-step answer on achieving the following efect on Jenkins CI, First of all - here is tools I can operate with:
Two Jenkins CI servers - Jenkins A and Jenkins B ;
Jenkins B cannot serve as data storage for builds, therefore the artifacts, test, etc. should be saved on Jenkins A :( ;
Apache Ant ( latest ) and NAnt ( latest ) .
The goal is to achieve the following: Ability to start build on Jenkins A, make source code and build on Jenkins B, but archive and show the artifacts again on Jenkins A.
As much I have googled, I found there is term widely used - "distributed build" ... is it the case here, too?
Currently using latest Jenkis CI version available on both machines ( Jenkins A and Jenkins B ).
What job config I need to use to be able to do such multi-Jenkins setup under my company domain?
You do not want to have a full Jenkins install on both machine.
What is sounds like to me is you should be installing Jenkins on machine A, and set up machine B as a slave node to that Jenkins installation. The Jenkins UI makes this very intuitive, but if you need details they are available here:
https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines
https://wiki.jenkins-ci.org/display/JENKINS/Distributed+builds
Once you've done that, you will need to explicitly configure your job so that it:
Archives whatever artifacts you need archived (you probably have this done already).
Builds only on the machine B slave node by entering the node name in "Restrict where this job can be built."

Resources