How to configure jenkins to upload build artifact to nexus? - jenkins

I have jenkins jobs that builds ios and android app and i want jenkins to upload those artifact to nexus after build is done.Is there any way to do it?
Thanks

If you are building the apps with Maven or Gradle or whatever (esp. the Android ones) a simple mvn deploy or gradle uploadArchives will do the trick. Same applies if you build the ios app with one of these tools.
In most other cases you can always do normal upload via the REST API.
Examples for the Maven and Gradle setup are in the eval guide and the examples to the Nexus book.

Use the Nexus Artifact Uploader Plugin, and set up a new job where you set a build step to Copy artifacts form another project, and a step to Upload artifact to Nexus

Related

choose artifact from artifactory to deploy pipeline job in Jenkins

Is this possible? Suppose I have 2 jobs. One for building artifact and upload it to artifactory with latest version. And another job to deploy the artifact to the server. But I would like to choose the artifact version. Supose A deploy was made and not working , so I redeploy and choose previous artifact (or the one I want to choose). Is this posible in jenkins in a pipleine project? Like a parametrized build or something like that.
Thanks
It will work with the pipelin job . I am it in pipeline job only.
Example: https://wiki.jenkins.io/display/JENKINS/Maven+Metadata+Plugin
Assume that you have 2 jobs .
Job A & Job B. (Both pipeline jobs.)
Job A -> Build and push the artifacts to Artifactory.
Job B -> Fetch the artifact from Artifactory and deploy.
Install the Maven Meta Plugin . https://wiki.jenkins.io/display/JENKINS/Maven+Metadata+Plugin
go to Job B
"This build is parametrerized" checkbox, from the drop-down that appears select the "List maven artifact versions",
configure the artifact you want to retrieve the versions
Name the parameter as deploy_version
In Job B - > Select the version & Click Build.
In pipeline script receive the selected version as param.deploy_version.
Since you know the artifact version and artifact URLs . You can use CURL/httprequest plugin in Jenkisn to download the necessary
artifact from Artifactory (I am using Maven Ansible artifactory
plugin to download)
Continue with your deployment.
According to this answer :
https://stackoverflow.com/a/34781604/3957754
The artifactory plugin for Jenkins has the option to "resolve" artifacts, i.e. download them from Artifactory. But this may require the Pro version with payment $_$
Download artifact using artifactory jenkins plugin (With Payment)
Configure your artifactory plugin
https://medium.com/#anusha.sharma3010/integrating-jenkins-with-artifactory-6d18974d163d
https://www.jfrog.com/confluence/display/RTF/Jenkins+Artifactory+Plug-in
In resolve section, you could download your artifacts
Download artifact using commandline and maven
configure maven and artifactory authentication
https://docs.gitlab.com/ee/ci/examples/artifactory_and_gitlab/
https://blog.bosch-si.com/developer/setting-up-maven-and-artifactory/
download artifact from artifactory
mvn org.apache.maven.plugins:maven-dependency-plugin:2.1:get \
-DrepoUrl=http://my_artifactory-url.com \
-Dartifact=groupId:artifactId:version
Source: How can I download a specific Maven artifact in one command line?

Publishing Artifacts without a Build

How can I upload binaries straight to Jenkins without running a build?
For example, I want to use a customized maven, without deploying it to all of my nodes.
Is there a neat way to somehow upload this zip straight to Jenkins? Without running a build that has a publish artifacts step?
Jenkins is built for keeping the artifacts that come out of a build job. It's not built for just uploading artifacts without building.
For what you want to do, use an artifact repository server like JFrog Artifactory, Sonatype Nexus or Archiva. These are built exactly for that purpose.

How to push npm project from jenkins to oneops

I have an npm project which I am using Jenkins for Continuous Integration. So I achieved build automation in Jenkins. Right now I am struggling how to push the build output to Oneops. I browsed couldn't find any solution.
Any help is appreciated.
It depends. Let's say you are deploying something like a React application that you are building in Jenkins. Maybe you run "npm run build" and your build creates an optimized application in the build/ subdirectory?
This is a process I run several times a day in response to a CI build.
I do this now in Jenkins, Jenkins run the build "npm run build."
I use a simple Maven deploy-file task to upload a ZIP archive to Nexus. (See the documentation for Maven deploy-file here: https://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html)
Then I configure the OneOps artifact component to download from Nexus - http://oneops.com/user/design/artifact-component
Admittedly, this may not be the NPM-focused way of publishing artifacts, but I found the using NPM to publish artifacts to Nexus had some limitations that I couldn't accept.
To take this a step further, I've configured by Jenkins build to call out to OneOps and trigger an environment variable update that triggers the deployment of code to OneOps.

How to promote non maven artifacts in Nexus?

I have a non maven project whose binaries get deployed to Nexus.
I used gradle's maven plugin to create the artifacts and publish it to Nexus
Now, the trouble is how do I promote this artifacts to release in Nexus? I tried looking up the M2 release plugin for jenkins but it looks for the pom file in my source code.
There are a number of Gradle examples including usage with the Nexus staging suite in the Nexus book examples and eval guide.

Publish to Artifactory copied from another project artifacts in Jenkins

So I got few separated jobs in Jenkins. The first one gets the project from a Git repository, builds it and produces artifacts. And another one has to copy certificates from the first job and publish them to Artifactory (tried to make it using the Artifactory plugin). But the thing is that the Artifactory plugin's available only in the Build job, there's nothing like "Generic-Artifactory integration" in second job's configuration.
Does anyone know what are the requirements for making the plugin work in the Publish job?
You can write a small shell script leveraging Artifactory REST API and execute it in your second, non-build job.
I have done a similar thing with maven and a zip file. I have deployed a zip with a build step in maven calling a deploy:deploy-file and setting my Artifactory repository in settings.xml and deploying directly on my artifactory repository.

Resources