Add maven capability to Team Services build agent - maven

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.

Related

Jenkins ERROR: Failed to parse POMs java.io.IOException: Cannot run program error=2, No such file or directory

In jenkins I am forcing the execution to happen in one of the slaves.
in jenkins configuration I have updated the JAVA_HOME and MAVEN location to the location where its installed in the slave. When I start the build in jenkins I receive the following error
ERROR: Failed to parse POMs
java.io.IOException: Cannot run program "/home/jmeter/jdk1.8.0_112/bin/java" (in directory "/home/jmeter/apache-jmeter-2.13/bin/workspace/MyProject"): error=2, No such file or directory
PS : /home/jmeter/apache-jmeter-2.13/bin/workspace/MyProject - This directory got created and does exist in the slave machine
Can someone please share their expertise in resolving it ?
I needed to add Tool location of JDK8 for machine i run test on.
looks like there is a problem in the MVN installation. PLS make sure in the global config that you have the required mvn installation.
jenkins-->manage-->configure look for Maven installations and use automatic installation for the required version
make sure you have the JDK installation in the same config file
After wasting one day trying with different things going through different suggestions I got nothing. But, it was actually very simple. Please add the JDK path as bellow to your JDK Path in Jenkins-
/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
You should assign the JDK in the Meta Data,The JAVA_HOME of system is not work for build.
Check your Maven version selected into the Manage Jenkins->Global Configurations->Maven->Maven Installations->Install from Apache->Version is same as installed on the server and your maven project.
You might have left out a few dependencies resulting in this issue.
Go back and download java and set the path as before:
To download, use
$yum -y install java-1.8*
Set the path to
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.242.b08-0.amzn2.0.1.x86_64
Note: Get your path using command
find /usr/lib/jvm/java-1.8* | head -n 3
This got resolved after adding maven_home and providing the path in the global properties.
Go to: Jenkins ⟶ Manage Jenkins ⟶ Global Properties ⟶ MAVEN_HOME [C:\Program Files\Apache\apache-maven-3.6.3-bin\apache-maven-3.6.3]
Just in case someone else runs into this. I was getting this error because someone setup the JDK in Global Tool Configuration to download a windows version of the JDK, but my instance of jenkins is running on linux. Once I made the change to use a linux version of the JDK my issue was resolved.

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

Couldn’t find any executable in apache-maven-3.3.3

I have a windows jenkins slave and I have download apache-maven-3.3.3 on it.
It is located C:\Users\myUsername\Desktop\apache-maven-3.3.3 This is copy and pasted from the windows explorer on my Windows slave.
Then when I point at this location in Jenkins and run a build. I get this error
Couldn’t find any executable in C:\Users\myUsername\Desktop\apache-maven-3.3.3
I have also tried Couldn’t find any executable in C:\Users\myUsername\Desktop\apache-maven-3.3.3\bin
This works just fine on my linux slaves. What is the difference? Why is this not working?
Maven changed the name of the executable in Maven 3.3 from mvn.bat to mvn.cmd. Jenkins recognized mvn.cmd since Jenkins 1.613 (see this commit). If you are on an earlier Jenkins version you can add a symlink from mvn.bat to mvn.cmd on windows as a workaround.
The executable is in the \bin folder (namely, mvn.bat). Try to point Jenkins to C:\Users\myUsername\Desktop\apache-maven-3.3.3\bin
First
Under your Windows machine
1. create an Environment Virable named MAVEN_HOME and set its value to C:\Users\myUsername\Desktop\apache-maven-3.3.3.
2. Add %MAVEN_HOME%\bin into your System PATH
Second
Go to
http://your-jenkins-server/computer/your-windows-slave/configure -->Node Properties-->Tool Locations-->(Maven)maven
and set its value to C:\Users\myUsername\Desktop\apache-maven-3.3.3 as well.
Third
Reconnect your jenkins slave, then rerun your job.
Well for me it was wrong setting for maven. Go to configure, under post build action, go to advanced setting and there fix the Maven version to be used, i changed it to maven 3.3.3 and it worked.
I am using Windows. The accepted answers does not work for me. So, I have to create a new Maven in Jenkins and select the option "Install automatically". Then it works.

Maven artifacts are deployed to a wrong location at when invoking Gradle install task on Team City CI

I'm trying to setup simple continuous integration system on my local PC. I use gradle as my build system (gradle wrapper option). One of the steps in the build process in to deploy build artifacts to a local repository (located at:
"{user_dir}/.m2/repository)". It works ok when I run it from local PC, but when it runs on Team City CI (version 9) it deploys it to a
"{windows_dir}\System32\config\systemprofile.m2\repository". This is probably some configuration issue but I couldn't manage to solve it. In the build logs I saw that it can't find the local repository in the settings.xml file. I've tried to add it but it didn't help. How can I configure Team City to use local repository folder in user directory?
I found out what was the issue. If you install Team City system services to run under admin account it will always use windows directory. In order to use the User's directory you need to install the services under that user account.
Source: https://confluence.jetbrains.com/display/TCD9/Maven+Server-Side+Settings.

Adding MSBuild Community Tasks as an Agent Requirement

My build script depends on the MSBuild Community Task targets. I'd like to make this an agent requirement. How can this be done in TeamCity 8.x?
What you can do is add an Agent Requirement (Step 8 of your build Configuration)
Now immediately after doing this your build agent will be incompatible - that is because there is no such environment variable as MSBuildCommunityTasksPath - I've made this up because Community Tasks does not install any.
The next thing you need to do is log into the build agent PCs that do have Community Tasks installed and add this environment variable:
the path should be either
C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks
or
C:\Program Files\MSBuild\MSBuildCommunityTasks
nb techincally it doesnt matter what you enter as this variable is just a flag indicating community tasks is installed
after you do this you need to restart your build agent
Now this paramter will be available in TeamCity and your build agent should be compatible. You can go to the Agents tab to check this. Agents -> <your agent> -> Agent parameters -> Environment Variables

Resources