No transfer protocol found while deploying an artifact using maven deploy in Azure DevOps - maven

When I am trying to deploy a JAR artifact to artifact feed in Azure DevOPS facing the below issue.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy-file (default-cli) on project: No transfer protocol found. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Below is my YAML code:
- task: Maven#3
displayName: 'Maven Deploy'
inputs:
mavenPomFile: 'pom.xml'
goals: 'deploy:deploy-file'
options: '-DgroupId="com.mycompany" -DartifactId="s-demo-cicd" -Dversion="1.0.1" -
Dpackaging=jar -Dfile="demo-1.0.1-mule-application.jar" -DgeneratePom="true" -
DrepositoryId="$AZURE_FEED_ID" -Durl="$AZURE_FEED_URL"'
I have added required dependencies in POM.xml file.
<distributionManagement>
<repository>
<id>demo-mule</id>
<url>https://pkgs.dev.azure.com/demo-mule/_packaging/demo-mule/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
Please help me understand where I need to make the changes or updates.

To pass a variable into the parameters of the Maven task, make sure you use the correct notation. It can be a bit confusing at times.
In this case use $(...) instead of $.... So your task would look like this:
- task: Maven#3
displayName: 'Maven Deploy'
inputs:
mavenPomFile: 'pom.xml'
goals: 'deploy:deploy-file'
options: '-DgroupId="com.mycompany" -DartifactId="s-demo-cicd" -Dversion="1.0.1" -
Dpackaging=jar -Dfile="demo-1.0.1-mule-application.jar" -DgeneratePom="true" -
DrepositoryId="$(AZURE_FEED_ID)" -Durl="$(AZURE_FEED_URL)"'

Related

Maven build with Github Actions - Couldn't not resolve dependencies

I'm struggling a little bit with Github actions.
I'm trying to build a project with Maven using Github actions. The project contains a dependency located in a repo within the same org.
I created a PAT with read/write privileges and wrote the following script:
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
# Added personal token
name: Maven Deploy
on:
push:
branches: develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v2
- name: Set up JDK 1.8
uses: actions/setup-java#v1
with:
java-version: 1.8
server-id: github
- name: Build with Maven
run: mvn -B package --file DynamoDB\ Service/pom.xml
env:
MENADEX_USERNAME: my_username
MENADEX_TOKEN: xxxxxxxxxxxxx
- name: Publish package
run: mvn deploy -f DynamoDB\ Service/pom.xml -s $GITHUB_WORKSPACE/DynamoDB\ Service/settings.xml
env:
MENADEX_USERNAME: my_username
MENADEX_TOKEN: xxxxxxxxxxxxxxxxxxxxxx
Github keeps complaining it couldn't find the artifact related to the dependency.
Settings.xml
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>Common</id>
<name>GitHub Menadex Apache Maven Packages</name>
<url>https://maven.pkg.github.com/Menadex/Ad360CommonObjects</url>
</repository>
</repositories>
</profile>
</profiles>
<servers>
<server>
<id>github</id>
<username>${env.MENADEX_USERNAME}</username>
<password>${env.MENADEX_TOKEN}</password>
</server>
</servers>
</settings>
This is what I keep receiving:
[ERROR] Failed to execute goal on project dynamodb: Could not resolve dependencies for project com.ad360:dynamodb:jar:1.0.0-SNAPSHOT: Could not find artifact com.ad360:common:jar:1.0.0-SNAPSHOT -> [Help 1]
210
[ERROR]
211
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
212
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
213
[ERROR]
214
[ERROR] For more information about the errors and possible solutions, please read the following articles:
215
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
216
##[error]Process completed with exit code 1.
Also, I see that the newly created PAT was never touched. (In admin sections, it says 'never used').

Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?

I am working from a private network, trying to a buildpipeline for a Maven project. To work with tools on our private network I am trying to use a Private Hosted Agent. Now I know there are some restrictions on reaching Maven Central from our network, normally we use a proxy through Nexus for this.
With the new Maven Upstream feature in Azure artifacts I thought I could use this as a 'proxy'.
Unfortunately the build is failing, it seems to try and reach Maven Central directly (not using my feed) which naturally fails. Below my output and settings
And finally my build output:
2019-10-02T07:27:06.0094285Z Task : Maven
2019-10-02T07:27:06.0094336Z Description : Build, test, and deploy with Apache Maven
2019-10-02T07:27:06.0094403Z Version : 3.158.0
2019-10-02T07:27:06.0094449Z Author : Microsoft Corporation
2019-10-02T07:27:06.0094522Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/maven
2019-10-02T07:27:06.0094582Z ==============================================================================
2019-10-02T07:27:06.8762822Z [command]C:\windows\system32\reg.exe query "HKLM\SOFTWARE\JavaSoft\Java Development Kit\1.8" /v JavaHome /reg:64
2019-10-02T07:27:06.8762932Z
2019-10-02T07:27:06.8763016Z HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Development Kit\1.8
2019-10-02T07:27:06.8763085Z JavaHome REG_SZ C:\Program Files\Java\jdk1.8.0_221
2019-10-02T07:27:06.8763156Z
2019-10-02T07:27:06.9319606Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -version"
2019-10-02T07:27:07.4696051Z Apache Maven 3.6.1 (d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T19:00:29Z)
2019-10-02T07:27:07.4700024Z Maven home: C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\..
2019-10-02T07:27:07.4709043Z Java version: 1.8.0_221, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_221\jre
2019-10-02T07:27:07.4725586Z Default locale: en_US, platform encoding: Cp1252
2019-10-02T07:27:07.4726158Z OS name: "windows server 2016", version: "10.0", arch: "amd64", family: "windows"
2019-10-02T07:27:07.5446027Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:07.7710829Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0375908Z ##[warning]The settings for the feed or repository already exists in the xml file.
2019-10-02T07:27:08.0492975Z SYSTEMVSSCONNECTION exists true
2019-10-02T07:27:08.0530287Z [command]C:\windows\system32\cmd.exe /D /S /C "C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd -f C:\DATA\Agent\_work\71\s\pom.xml -s C:\DATA\Agent\_work\_temp\settings.xml package"
2019-10-02T07:27:09.9877350Z [INFO] Scanning for projects...
2019-10-02T07:27:10.0851393Z [INFO]
2019-10-02T07:27:10.0897285Z [INFO] ---------< com.ontestautomation.javafortesters:JavaForTesters >---------
2019-10-02T07:27:10.0941394Z [INFO] Building JavaForTesters 1.0-SNAPSHOT
2019-10-02T07:27:10.0942123Z [INFO] --------------------------------[ jar ]---------------------------------
2019-10-02T07:27:10.6741134Z Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom
2019-10-02T07:27:31.8954116Z The process 'C:\DATA\Choco\lib\maven\apache-maven-3.6.1\bin\mvn.cmd' failed with exit code 1
2019-10-02T07:27:31.8954401Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955258Z Could not retrieve code analysis results - Maven run failed.
2019-10-02T07:27:31.8955423Z [INFO] BUILD FAILURE
2019-10-02T07:27:31.8955503Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955591Z [INFO] Total time: 21.842 s
2019-10-02T07:27:31.8955658Z [INFO] Finished at: 2019-10-02T07:27:31Z
2019-10-02T07:27:31.8955759Z [INFO] ------------------------------------------------------------------------
2019-10-02T07:27:31.8955928Z [ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.36.215] failed: Connection timed out: connect -> [Help 1]
2019-10-02T07:27:31.8956093Z [ERROR]
2019-10-02T07:27:31.8958075Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2019-10-02T07:27:31.8958201Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2019-10-02T07:27:31.8958274Z [ERROR]
2019-10-02T07:27:31.8958331Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2019-10-02T07:27:31.8958423Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
2019-10-02T07:27:33.1008909Z No test result files matching C:\DATA\Agent\_work\71\s\**\surefire-reports\TEST-*.xml were found, so publishing JUnit test results is being skipped.
2019-10-02T07:27:33.1015611Z ##[error]Build failed.
2019-10-02T07:27:33.1185161Z ##[section]Finishing: Maven ```
Anyone any ideas?
Thanks!
Can I reach Maven central through Azure DevOps artifacts from a private hosted agent?
The answer should be yes.
The reason why it still reach Maven Central directly is that all pom files inherit from the maven super POM:
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
which contains this entry:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
So, we could overwrite it in your pom with Azure DevOps artifacts:
<repositories>
<repository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://pkgs.dev.azure.com/xxx/xxx</url>
<releases><enabled>false</enabled></releases>
</pluginRepository>
</pluginRepositories>
Or you can use the maven Mirrors to to replace a particular repository with your own internal repository.
Check more details about this issue, please check this ticket.
Besides, you could also set the Proxies in the your pom.
Hope this helps.

Execution default of goal com.github.tntim96:jscover-file-maven-plugin:1.0.19:jscover failed: jscoverage_serializeCoverageToJSON is not defined

I am trying to implement JSCover to check the coverage of my code [js files].I have added jscover-file-maven-plugin to the pom.xml of my app. When I try to run maven install on the app, my build is getting failed with following message:
[INFO] --- jscover-file-maven-plugin:1.0.19:jscover (default) # webUi ---
[INFO] Ran JSCover instrumentation
[INFO] BUILD FAILURE
[ERROR] Failed to execute goal com.github.tntim96:jscover-file-maven- plugin:1.0.19:jscover (default) on project webUi: Execution default of goal com.github.tntim96:jscover-file-maven-plugin:1.0.19:jscover failed: jscoverage_serializeCoverageToJSON is not defined"
Can anyone explain what is happening here?enter code here
It doesn't look like any tests were run. If you're not sure of the configuration, you can compare with the working example at https://github.com/tntim96/JSCover-samples. You can also post your configuration and directory structure.
You can try the 1.0.20-SNAPSHOT, which has more logging (but requires Java 8), with the following:
<pluginRepositories>
<pluginRepository>
<id>Sonatype repository</id>
<name>Sonatype's Maven repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>
</pluginRepositories>

Maven: Release:perform fails, but deploy works.

My pom file looks like this :
<distributionManagement>
<repository>
<id>maven-s3-release-repo</id>
<name>S3 Release Repository</name>
<!-- http://bigpetstore.s3.amazonaws.com/maven/ -->
<url>s3://bigpetstore/maven</url>
</repository>
</distributionManagement>
When I run , "mvn deploy", I get my project published to the correct repository.
However, if I run "release:prepare" followed by "release:perform", I get the following error:
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project BigPetStorePro: Deployment failed:
repository element was not specified in the POM inside distributionManagement element or
in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
So, my question is: Why is it that "mvn deploy" is able to easily deploy my contents, however, mvn release:prepare fails to see the contents of the distributionManagement?
Clearly, the tag is present.

Specifying new Maven repository

Good day!
I've specified in my project's pom.xml file a new repository. So before tags I've added this configuration
<repositories>
<repository>
<id>maven-db-plugin-repo</id>
<name>maven db plugin repository</name>
<url>http://maven-db-plugin.googlecode.com/svn/maven/repo</url>
<layout>default</layout>
</repository>
</repositories>
like indicated here
But, when i'm trying to execute mvn db:update, I'm getting this error:
[ERROR] No plugin found for prefix 'db' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/andriy/.m2/repository), central (http://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException
Any suggestions of what I'm doing wrong?
Thanks
Update
I've also added this dependence
<dependency>
<groupId>com.googlecode</groupId>
<artifactId>maven-db-plugin</artifactId>
<version>1.3</version>
<type>jar</type>
</dependency>
And still getting those warnings:
[WARNING] The POM for com.googlecode:maven-db-plugin:jar:1.3 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for com.googlecode:maven-db-plugin:1.3: Plugin com.googlecode:maven-db-plugin:1.3 or one of its dependencies could not be resolved: Failed to read artifact descriptor for com.googlecode:maven-db-plugin:jar:1.3
Just adding a repo isn't enough to make a plugin work. You have to configure the plugin in your pom, too. There's an example of configuring the maven-db-plugin at the bottom of the project's home page.
The maven-sql-plugin has better documentation. If it fits your needs, you might just use that instead.
I think you have to have the following configuration:
<pluginRepositories>
<pluginRepository>
<id>maven-db-plugin-repo</id>
<name>maven db plugin repository</name>
<url>http://maven-db-plugin.googlecode.com/svn/maven/repo</url>
<layout>default</layout>
</pluginRepository>

Resources