I am trying to upload a jar to S3 via gitlab CI pipeline.
On deploy stage a run a job with a script.
- mvn -s ../aws-settings.xml deploy
my aws-settings.xml file looks like this (AWS access keys are set in gitlab CI as environment variables)
<settings>
<servers>
<server>
<id>artifact-s3-repo</id>
<username>${env.AWS_ACCESS_KEY_ID}</username>
<password>${env.AWS_SECRET_ACCESS_KEY}</password>
<configuration>
<region>${env.AWS_DEFAULT_REGION}</region>
</configuration>
</server>
</servers>
</settings>
and in my pom.xml I set distribution managment as
<distributionManagement>
<repository>
<id>artifact-s3-repo</id>
<url>s3://<myartifactbucketname>/</url>
</repository>
</distributionManagement>
my pipeline fails on deploy stage with the following output
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project <my-project-name>: Failed to deploy artifacts/metadata: Cannot access s3://<myartifactbucketname>/ with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access s3://<myartifactbucketname>/ using the registered transporter factories: WagonTransporterFactory: java.util.NoSuchElementException
I need some hints to configure the connection to aws properly (without adding additional plugins if possible). Thank you in advance.
I didn't manage to publish artifact to S3 via maven deploy , but I implemented AWS CLI commands in my pipeline script
Related
Im trying to gain some experience in working with Nexus and TeamCity.
To do so i set both servers up on my local machine and configured a pet project thats located on github.com in a private repo.
But i can't get my TC-Build to run because the Maven deploy step fails with following message.
[14:58:55][Step 2/2] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Worm: Failed to deploy artifacts: Could not transfer artifact org.test.worm:Worm:jar:1.0.0 from/to local_nexus (http://localhost:8081/repository/org.test): Transfer failed for http://localhost:8081/repository/org.test/org/test/worm/Worm/1.0.0/Worm-1.0.0.jar 401 Unauthorized
Seems like it fails due to wrongly configured authorization but i can't find the mistake.
In my projects pom.xml it is configured like this
<distributionManagement>
<repository>
<id>local_nexus</id>
<name>Deployment</name>
<url>http://localhost:8081/repository/org.test</url>
</repository>
</distributionManagement>
and in my mavens settings.xml like this
<server>
<id>local_nexus</id>
<username>admin</username>
<password>admin</password>
</server>
Im using the default admin user (user/pw is correct, logging into nexus with the same user) that is created when installing nexus. Same user that created the repository.
TC running under localhost:8080 and Nexus under localhost:8081
Please tell me what i configured wrongly or what i forgot.
Using mvn help:effective-settings i could confirm that the settings.xml was configured correctly. But it made me realize that my TeamCity Server was using a different (its own) maven instance than my local machine. So the solution was to either set the maven-home for TeamCity or to configure the settings.xml of the other maven instance.
Stupid mistake i should have noticed way sooner.
I have a maven pom project with defined distributionManagement section in pom.xml
<project>
...
<distributionManagement>
<repository>
<id>my-repo</id>
<url>http://nexus.my.local/repository/my-private</url>
</repository>
</distributionManagement>
</project>
in the settings.xml file I have set up the servers section
<servers>
<server>
<id>my-repo</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
in jenkins, I binded the credentials to these variables
But doing mvn clean deploy gives me following error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project XY:
Failed to deploy artifacts:
Could not transfer artifact XY:pom:1.0.0 from/to my-repo (http://nexus.my.local/repository/my-private):
Failed to transfer file: http://nexus.my.local/repository/my-private/XY-1.0.0.pom.
Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
When I echoed the variable ${CI_DEPLOY_USERNAME} in shell before build, it gave me **** output -> I think that is ok.
Where else should I provide the variables? Is my project's settings.xml get used in maven deploy command?
Using environment variables as properties in Maven requires that they're prefixed with env., so it should be:
<servers>
<server>
<id>my-repo</id>
<username>${env.CI_DEPLOY_USERNAME}</username>
<password>${env.CI_DEPLOY_PASSWORD}</password>
</server>
</servers>
Reference:
http://maven.apache.org/pom.html#Properties
I need to upload my build artifact to S3 bucket. For this purpose, I'm trying to use s3-storage-wagon maven plugin
This is my configuration in pom.xml:
<distributionManagement>
<repository>
<id>s3.artifacts.release</id>
<url>s3://${artifactrepo.url}/release</url>
</repository>
<snapshotRepository>
<id>s3.artifacts.snapshot</id>
<url>s3://${artifactrepo.url}/snapshot</url>
</snapshotRepository>
</distributionManagement>
<extensions>
<extension>
<groupId>com.gkatzioura.maven.cloud</groupId>
<artifactId>s3-storage-wagon</artifactId>
<version>1.0</version>
</extension>
</extensions>
settings.xml
<server>
<id>s3.artifacts.release</id>
<username>Access key ID</username>
<password>Secret</password>
</server>
<server>
<id>s3.artifacts.snapshot</id>
<username>Access key ID</username>
<password>Secret</password>
</server>
During Maven deploy this plugin fails with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project pipeline: Failed to retrieve remote metadata com.xxx:xxx:0.0.4-SNAPSHOT/maven-metadata.xml: Could not transfer metadata com.xxx:xxx:0.0.4-SNAPSHOT/maven-metadata.xml from/to s3.artifacts.snapshot (s3://my-backet/snapshot): Could not authenticate: Access Denied (Service: Amazon S3; Status Code: 403; Error Code: AccessDenied; Request ID: 8KJHKHFKHFGA48; S3 Extended Request ID: 2j/bW/INn+qCzVqwer+Fawv75qwerkUPmO7flQa8z34523445werrtwertGTs919tJpYoM=) -> [Help 1]
We are using GUI S3 client for Windows and are able to access the target S3 bucket without any issue. What may be wrong with our s3-storage-wagon maven plugin configuration?
Looks like your AWS credentials for S3 do not have upload (PutObject most likely) permission. The portion of the message telling you this is:
Could not authenticate: Access Denied (Service: Amazon S3;...
Or perhaps you need to setup your ~/.aws/credentials file so that the default profile is able to access the S3 bucket you are using.
If you need to use alternate profiles (the non-default profile in your ~/.aws/credentials file) you will likely need to specify the profile using one of the many ways AWS SDKs support this. I would start by trying AWS_PROFILE=my-profile such as the following (assuming bash):
AWS_PROFILE=my-profile mvn deploy
See https://github.com/gkatzioura/CloudStorageMaven/tree/master/S3StorageWagon#authentication for further info on how to provide credentials to this plugin.
I am trying to deploy a CAR file to a ESB instance. I am following the instructions here: https://docs.wso2.com/display/DVS370/Deploying+a+CAR+File+with+the+Maven+Plug-In
But when I run the command:
mvn clean deploy -Dmaven.car.deploy.skip=false
I get an error that many other people get.
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to configure plugin parameters for: org.apache.maven.plugins:maven-deploy-plugin:2.4
check that the following section of the pom.xml is present and correct:
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>repo</id>
<name>Repository Name</name>
<url>scp://host/path/to/repo</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>repo</id>
<name>Repository Name</name>
<url>scp://host/path/to/repo</url>
</snapshotRepository>
</distributionManagement>
Cause: Class 'org.apache.maven.artifact.repository.ArtifactRepository' cannot be instantiated
I don't want to deploy it to a repository, unless I am understanding this wrong.
I created a Maven Multi Module Project to package up the Java Mediator, the ESB Config Project and the Composite Application Project.
Why is this failing?
What is the correct way to deploy a car manually?
To deploy a car file 'manually' you can simply execute a "mvn clean install" and copy the .car file from the target directory and copy to <CARBON_HOME>/repository/deployment/server/carbonapps which hot-deploys the carbon app to ESB server.
http://numberformat.wordpress.com/2011/05/18/nexus-repository/
I am following the above link to setup Maven and Nexus, everything new. I couldn't left a new comment there so I post here.
After so long, I am in another company, when I tried to setup a simple sample in my local PC, I got this error in "mvn deploy" to the simple Maven my-app sample. I installed the simple Nexus Open Source w/o Tomcat.
[WARNING] Could not transfer metadata com.mycompany.app:my-app:1.0-SNAPSHOT/maven-metadata.xml from/to snapshots (localhost:8081/nexus/content/repositories/snapshots): Access denied to: localhosts:8081/nexus/content/repositories/snapshots/com/mycompany/app/my-app/1.0-SNAPSHOT/maven-metadata.xml , ReasonPhrase:Forbidden.
In your settings.xml located in MAVEN_HOME/conf you have to add in servers section
<server>
<id>nexus-releases</id>
<username>deploy</username>
<password>123456</password>
</server>
And in your pom must looks like
<distributionManagement>
<repository>
<id>nexus-releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases</url>
</repository>
</distributionManagement>
Ids have to be the same.
Richard Seddon resolved my issue in nexus-users group.
Add this to nonProxyHosts:
localhost
You need to be authorized to run deployment. This is done by having the server section in your settings.xml. Check out the Nexus eval guide, specifically the publishing section and the sample projects in there for more detail.