cloudbees jenkins maven installation missing - maven

I am getting following error when building a project in jenkins:
ERROR: A Maven installation needs to be available for this project to be built.Either your server has no Maven installations defined, or the requested Maven version does not exist.
[cloudbees-deployer] Skipping deployment as build result is FAILURE
Finished: FAILURE
In Jenkins settings, I tried both options: automatic installation from apache as well as use pre-installed maven on dev#cloud.
What might be missing?

Related

SonarQube not failing my local maven build, but is failing our CI build

The company I work for uses SonarQube as part of our CI build.
I have configured my settings.xml file according to: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-maven/
I am pointing my local build at the same SonarQube server that is used by our CI build.
My build fails on the CI server as a result of the SQ analysis.
When I perform mvn sonar:sonar on my machine I am expecting a failed build with some helpful error messages. Instead, the build succeeds.
What am I doing wrong?

How can I resolve a 401 failure when deploying a Maven artifact from Jenkins to Artifactory using the Artifactory Plugin and the Credentials Plugin?

I use Jenkins to build a Maven project.
I have the Jenkins Credentials Plugin and the Jenkins Artifactory Plugin.
I have added my Artifactory credentials in the Credentials config.
I have configured the Artifactory plugin to use the Credentials and have set up the server URL. Test Connection works and reports back that it has found the server.
My project's POM specifies the correct Artifactory paths for the repository and the snapshotsRepository in the distributionManagement section.
My Jenkins project build is configured to do a mvn deploy.
In my local build, from my development machine, I can deploy to the Artifactory server (I have configured the credentials in my settings.xml.
However, in my Jenkins job, I want to use the Artifactory plugin and the Credentials int he Credentials plugin. When I build, I get the following
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://xxxxx/artifactory/libs-release-local
Uploading: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.war
Uploading: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.pom
Notifying upstream projects of job completion
Join notifier requires a CauseAction
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
and the following stack trace
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project querynator:
Failed to deploy artifacts: Could not transfer artifact xxx:war:3.01 from/to dwCentral (http://xxxxx/artifactory/libs-release-local):
Failed to transfer file: http://xxxxx/artifactory/libs-release-local/xxx/3.01/xxx-3.01.war.
Return code is: 401, ReasonPhrase: .
This indicates to me the issue is with credentials, particularly since I can deploy from my dev box (using credentials in settings.xml), but not from Jenkins.
I have tried deploying a new version. I have tried deploying snapshots. This is not a version issue.
How can I I resolve this? How can I troubleshoot this further?
When using the Artifactory plugin in Jenkins, you should not use mvn deploy in the main build task. That uses the Maven Deploy Plugin, and hence will try to use credentials stored in the settings.xml file.
Instead, use mvn install as the main build task, and set up a new post-build task to Deploy Artifact to Repository.
This allows you to define the server, repository locations, and credentials to use.
Assuming you have already configured the credentials properly. If you have already deployed version lets say x.y.z to the artifactory once. Executing the command
mvn deploy
again for the same version would also result in the
Return code is: 401, ReasonPhrase: Unauthorized.
You can try updating the version to x.y.a which has never been deployed, the job should just run fine.
More from the documentation at Maven Lifecycle Basics
deploy - done in the build environment, copies the final package to
the remote repository for sharing with other developers and projects.
and assuming that you understand What exactly is a Maven Snapshot and why do we need it? and agree upon the fact that once a project is shared across things shouldn't be changing on the fly for consumers, the deploy phase is not permitted for the same version more than once.

local sonar analysis using a remote sonar server

I am doing a sonar analysis from my machine using a sonar instance on a remote server.
Local machine: Window7, apache-maven-3.2.5
Remote sonarcube server: sonarcube Version 3.7.3
I am using below command from command prompt:
mvn sonar:sonar -Dsonar.jdbc.url=<jdbcurl> -Dsonar.host.url=<sonarserver url>
I have defined a sonar profile for running the same
Whe I run the said mvn command, then I am getting below error:
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project builder-allmodules: Can not execute SonarQube analysis: Can not execute Findbugs: java.lang.RuntimeException: edu.umd.cs.findbugs.NoClassesFoundToAnalyzeException: No classes found to analyze in mymavenproject\target\classes *xyz.jar *F:\m2\repository\commons-io\commons-io\2.4\commons-io-2.4.jar *abc.jar *lmn.jar aaa.jarbbb.jar *ggg.jar
mymavenproject\target\classes: doesn't have any classes, instead, there is bundled jar at mymavenproject\target\ which contains all the classes
Also, another issue is that it is trying to analyze all the dependent jars also which should not be the case as I need sonar analysis for my project only
Can you let me know what I might be missing?
Because you've included FindBugs rules in your analysis profile, you're required to provide unbundled classes to the analysis.

Integrating sonarqube with Jenkins

I am trying to run sonar sonar:sonar by integrating sonarqube and jenkins. While doing, am getting the below error.
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project iwm_common: Can not execute SonarQube analysis: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext -> [Help 1]
Jenkins version - 1.612
Sonarqube version - 3.6
JDK-1.7.0_76
Maven - 3.1.1
Jenkins WAR is deployed in server A and sonarqube is deployed in server B. I have not installed sonar-jenkins plugin in Jenkins.
Can anyone let me know whether sonar-jenkins plugin is mandatory to be installed in jenkins to integrate jenkins with any sonar server (eg:sonarqube).
If the answer is YES, then after installation of the required plugin, will adding the sonar server (eg:sonarqube) information under Manage Jenkins -> Configure system -> sonar resolve the above error ?
The error is related to sonar-maven-plugin and this plugin is not used in any of the project's pom.xml. Can anyone please explain whether this plugin gets referred as a part of sonar:sonar goal. Thanks.
The versions you specified are not compatible for running sonar analysis.
Please upgrade SonarQube version (current is 5.1.1) which requires
Java 1.7-1.8
SonarQube 5.0 or 5.1.1
Sonar-runner 2.4
Using latest version of sonarqube resolved the issue mentioned.

maven error while running sonar from jenkins job

I am trying to implement Sonar in Jenkins CI using maven build tool.I am using Linux machine to build maven with Sonar.
maven is successfully installed. I have tried to configure maven path in Jenkins Configuration,
maven is installed .
whenever I run the job getting below error.
java.io.IOException: Cannot run program "mvn" (in directory
\"/directorypath"): java.io.IOException: error=2, No such file or directory""
as I understood from error that its unable to find out maven in Job directory. what configuration should needed so job can take by default maven path where is installed.
I have searched lot on internet, but could not helped.
Try without mvn in the commands
Eg clean install package

Resources