How to download snapshot artifacts from AWS S3 Repository? - maven-3

I have uploaded snapshots to AWS S3 for repository management. How can I download snapshot artifacts from aws s3 repository?
I have provided server details in setting.xml
<settings>
<servers>
<server>
<id>repo.teamed.io</id>
<username>AKIAI9NNNJD5D7X4TUVA</username>
<password>t5tZQCwuaRhmlOXfbGE5aTBMFw34iFyxfCEr32av</password>
</server>
[...]
</servers>
[...]
</settings>
I am able to upload artifacts to S3. But not able to download it.
I tried it through
<mirror>
<id>repo.teamed.io</id>
<mirrorOf>*</mirrorOf>
<url>s3://repo.teamed.io/snapshots/</url>
</mirror>

Related

Upload git repo to S3 bucket from Jenkins without plugin

I am trying to upload git repo through Jenkins job. I cant able to find any documentation related to file upload through Jenkins job. Can any please let me know how to upload git repo from Jenkins job to S3 bucket.
Thanks in advance.
You may use aws cli to accomplish that.
Install aws cli for on the server jenkins is hosted in and make sure jenkins user can use it.
In your Job, set the following Environment Variables:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
In your jenkins job command use:
aws s3 cp . s3://target-bucket/target-path/ --recursive
And so, your target path will have all the codebase after job completes.

How to upload artifact after Jenkins build to Nexus

I have a project structure like this:
- parent-project : pom.xml
+ child-project: pom.xml
+ child-project-2: pom.xml
I would like to upload the artifact of child-project to Nexus, so in pom.xml file of my child-project, I defined:
<distributionManagement>
<repository>
<id>nexus</id>
<url>http://my-repo:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>nexus</id>
<url>http://my-repo:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
And when I run the child-project with mvn clean deploy from eclipse, the jar file of child-project is uploaded to my-repo nexus repository as expected.
In Jenkins I have an job which is configured with the parent-project pom.xml. Now I would like to publish the artifact of my child-project to nexus after jenkins finished the build process. What I have done so far is:
Downloaded and installed the Nexus Platform Plugin in Jenkins
Configured the Nexus Repository Manager Servers with the credential to my Nexus 3.x Server in Jenkins System Configuration
In the Post-Build tab, I added a new Nexus Repository Manager Publisher with the Info about my nexus repository but now getting stuck at the Maven Artifact session as below:
What make me confused here are:
what should I put in the Maven Artifact session? I tried child-project/target/child-project-0.0.1-SNAPSHOT.jar but it did not work. Jenkins threw an exception
java.io.IOException:
child-project/target/child-project-0.0.1-SNAPSHOT.jar does not exist
Why do I need to specify the version of the artifact here? Does it mean that every time I change the version of my child-project, then I have to come here and modify the version?
If I already defined in pom.xml of my child-project the session with Info about the Nexus repo, why do I need to define it here again?
Is it possible that I configure the job build directly with mvn clean deploy like I did in eclipse to push the artifact to nexus? If yes then I dont need the Nexus Repository Manager Publisher anymore? And how can I configure the authentication for the nexus server like what I have in setting.xml in my /.m2 folder?
Can anyone help me to clarify the points above? Thank you very much!
you don't need the plugin
you can run maven clean install deploy from shell in your job
I'm using pipeline syntax so it's actual code but you can use jenkins ui
to create a shell step

Is it possible to upload Jenkins artifacts to Artifactory even if the build fails?

We are using the "Generic-Artifactory Integration" (with legacy pattern) in our Jenkins jobs to upload artifacts.
Is it somehow possible to upload the artifacts even if the build fails?
I don't seem to find an option on the configuration page (Freestyle build).
It isn't a good practice to upload an artifact if your build fail. I recomend you to create a new pipeline or to edit your actual pipeline.
If your artifact is building sucessfully but your pipeline if failing you can upload it using Jfrog Cli with this command in your pipeline code:
For packed (jar, zip...) artifact:
jfrog rt upload "JENKINS_PATH_TO_YOUR_ARTIFACT/*" YOUR_ARTIFACTORY_REPO/
For unzip or unpacked artifact:
jfrog rt upload --flat=false "JENKINS_PATH_TO_YOUR_ARTIFACT/*" YOUR_ARTIFACTORY_REPO/
Check Jfrog Cli manual:
Jfrog Cli
Check my post with similar task using Bamboo: Upload artifact to Jfrog Artifactory using Jfrog CLI

jenkins arifacts server configuration for nexus

I am newly learning Jenkins CI tool. I have issue while deploying artifacts from Jenkins to nexus. Here i attached screen shot Jenkins error snap with my pom file and maven setting file configuration.
Pom.xml
<distributionManagement>
<snapshotRepository>
<id>nexus-snapshots</id>
<url>http://localhost:8080/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
maven/setting.xml
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
Could please some one help me on this issue ? Many thanks.
Your using the artifactory plugin to upload to nexus, artifactory is a different repository manager.
Also your url to nexus is wrong, should be something like http://localhost:8080/nexus/content/repositories/dev_repo
Also if you've already configured your maven to upload to a repo, then just run mvn publish.

How to remove/delete an artefact via Maven in a remote Nexus repo?

How can I use maven in an 'undeploy' fashion to remove an artefact deployed to the nexus staging repo?
I currently execute the a command like below for deployment:
deploy:deploy-file -Durl=${bamboo.ArtefactsNexusUrl} -DrepositoryId=${bamboo.nexusRepoId} -DgroupId=${bamboo.GroupId} -DartifactId=${bamboo.ArtefactName} -Dversion=${bamboo.inject.VERSION} -Dfile=${bamboo.ArtefactName}-${bamboo.inject.VERSION}.${bamboo.ArtefactExtension} -Dpackaging=${bamboo.ArtefactExtension}
You can drop the whole staging repository with the Nexus Staging Maven Plugin or via the Nexus user interface. Check out the documentation in the book.

Resources