Nexus integration with Jenkins - jenkins

Is there a way to list all the version uploaded in Nexus repositories.
I am working with Jenkins, and trying to show the versions uploaded in Nexus repositories.
EDIT:
I am not using MAVEN releases, i have the compresses files as zip.
The format we have is ,
ABCD releases
com.abc.abcd
appname
v1.0.0
app_v1.0.0.zip
How do i use Repository connector /Artifact resolver to configure to list all the releases under ABCD releases.

yes with jenkins nexus plugin you can make a parametrized job to display a specific version before the job start.
more detail look at this page
https://wiki.jenkins-ci.org/display/JENKINS/Repository+Connector+Plugin

Related

Is there a way to upload only release version to nexus

I am new to Jenkins. I am running my jobs using Jenkins declarative pipeline. My jobs has both snapshot version and release version. I want to push only release version to nexus (the reason is just to make sure it is not very much crowded in nexus). Can i control this in my pipeline script something like running multiple steps like, if my pom version has SNAPSHOT version, don't run nexus stage and if my pom has release version run nexus stage. is it possible to control this scenario in Jenkins pipeline. please assist
Depending on how you know is a SNAPSHOT or a RELEASE version. For example if you use git branches (develop = SNAPSHOT , master = RELEASE) you can use GIT_BRANCH variable in order to select if you must deploy push to nexus
If you must read it directly from pom.xml, read this:
Extract version ID from POM in a Jenkins pipeline
There you get the version and select if is a SNAPSHOT or RELEASE and the upload the file acoordingly.
Hope it helps

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?

Trigger jenkins build (maven) only if version not in nexus

I'd like to trigger Jenkins build only if version specified in pom.xml is not available in my nexus repository. Any help appreciated :)
I could disallow nexus to overwrite existing version, but it is currently not an option

How to trigger a Jenkins build on a new artifact in Artifactory?

Can Artifactory be used as "SCM" or source in Jenkins to trigger the builds on an particular artifact deploy?
Don't see (or miss it) anything similar in the Artifactory Jenkis plugin description (and on Jenkins side)
This could be needed for instance if there is only access to the Artifactory repository and not to the SCM with code the binaries are coming from.
Such functionality looks to be availble for Nexus (via nexus-webhook-plugin). Hard to believe that this feature is missing for Artifactory.
It's maybe not as elegant as a hook, but I believe the URLTrigger Plugin will achieve what you're looking for. Listed in their use cases:
This plugin enables users to check if new artifacts (such as binaries) have been deployed in a repository (managed for example by a repository manager such as Sonatype Nexus, JFrog Artifactory, Apache Archiva and so on).
It allows you to check the last modification date and inspect the contents of the response for changes.
You would have to use a polling interval instead of relying on Artifactory to notify Jenkins via a hook, but in my experience polling is relatively innocuous even with lots of polls at high intervals.
Now you can use Enable Artifactory trigger in a newer version.
Go to Build Triggers and check the Enable Artifactory trigger checkbox.
More Detail on GitHub Support for Artifactory trigger

Jenkins & Artifactory

On a server running ubuntu 12.04 I have installed jenkins 1.532.1 and artifactory 2.6.4.
Both of then are running fine separately. I also have maven 2.
With jenkins, I can build maven java project with sources on subversion.
With maven I can use Artifactory.
The problem is with the artifactory plugin for jenkins.
I added an artifactory server with credentials. Using connection check tell me : "Found Artifactory 2.6.4". It seems to be ok.
But when I create a maven job, in post build actions, I choose Deploy artifacts to artifactory. My server is already selected in the artifactory server but nothing is available in the repositories.
What can I do. Do I have to configure something special in Artifactory ?
I had also this issue, the problem comes from a refresh of Jenkins Plugin.
To deal with that issue, you should:
open your job
add a task for artifactory
save your job
Open again your job
Now you should be able to see your repositories.
Conclusion: You should add/save and reload your job to see your list of repo of artifactory.
I also have this problem, when switching from one artifactory server to another and it looks like a bug for me.
But if I save the settings once without a "non-selectable" repository and access the configuration of the job again, the repositories will be shown.
Ok, so after a very long time I tried again and ... I don't know why but now (I'm quite sure it was not working few months ago) the solution given by aorfevre and user3424040 are working.
I have also upgraded jenkins to 1.565.1 and the artifactory plugin to 2.2.3 and now there is a Refresh Repositories button in the Deploy artifacts to Artifactory task.
For the "Generic-Artifactory Integration" I had to configure Artifactory a bit. I added a group 'deployers' and a user 'deploy' in that group. Also I added a Permission Target for the LOCAL repositories where the group was granted deploy permissions.

Resources