creating a local repository in Artifactory - ant

I've just started installing Jenkins along with Artifactory and Ivy at our company.
Jenkins will be calling our ant build scripts and these scripts will then turn to Ivy to retrieve jars from the local repo (only).
We would like to have 2 local repositories : 1 for our local artifacts and 1 for 3rd party jars.
Our intent is to make sure developers retrieve only 3rd party jars that have been "approved" by admin in Artifactory.
The build scripts would then fetch from the local repository.
So my questiona are :
How do we setup a local repository to include the built artifacts?
How are 3rd party jars retrieved by Artifactory if it has no access to internet?
Is there a better way of doing this?

I'm not sure if I'm missing something, but setting up the local repository for your build artifacts should be straightforward, just follow the instructions in the Artifactory docs.
You would need to configure your build system to publish new artifacts to Artifactory. This is also straightforward if you're using a standard dependency management tool like Maven or Ivy, and is covered in the Artifactory docs.
Keeping a separate repo for 3rd party JARs is also not too hard; at my company we do this by submitting the JARs to source control, which triggers a build in our CI system that publishes the JARs to Artifactory.
If you want to give more details of your build and CI setup I can add additional guidelines.

Related

How to deploy delphi exe output to artifactory using jenkins

I use a script in Jenkins to build delphi projects and I want to deploy their .exe outputs to Artifactory server but I dont know how. Is there any plugin to deploy exe files to Artifactory?
Is it a good idea to deploy them to Artifactory?
The best would be using the Jenkins Artifactory plugin.
The plugin allows your build jobs to deploy artifacts automatically to Artifactory and have them linked to the build job that created them.
The support for generic (freestyle) builds is probably the most suitable one for deploying the .exe files. As part of the support for generic builds, you will be able to defined patterns for selecting which files would be deployed and to where.

Repository manager that manages binary dll files (Embedded C/C++ project artifacts) and that integrates with Jenkins

Is there any Repository manager that manages the binary dll files and also integrates well with the Jenkins?
Can Nexus be used to manage the dll files as these files are created as a part of Embedded C/C++ Projects and not sure if Nexus Artifact Manager supports/integrates well with such Projects as it mainly supports the Java projects?
Is there a way to automatically manage the upload and download of such project artifacts from Nexus/other artifact managers without the use of POM file?
Suggest in case there are other Artifact Managers that supports binary artifacts.
Artifactory can be used to store any type of binaries.
Starting with Artifactory 4.0, you can create generic repositories which allows uploading packages of any type. You will not need to upload any POM files and Artifactory will not need to calculate any metadata (for example Maven metadata).
To deploy files you can use the REST API or the UI, for example:
curl -uUSER:PASS -T file.dll http://localhost:8081/artifactory/dll-local/path/to/file.dll
If you have a certain layout you would like to use for this repository you can create a custom layout and associate it with the repository. This can be useful for automatic snapshot/integration versions cleanup and other module management tasks.
Disclaimer: I'm affiliated with Artifactory
The Nexus repository manager is java oriented, but can be used to store any files you want. Binaries of all types or even just text configuration files.
To automate the file upload process, you can use maven from command line:
mvn deploy:deploy-file -DgroupId=com.you -DartifactId=file -Dversion=1.0 -Dpackaging=exe -Dfile=c:\out\file.exe -Durl=http://yourserver/nexus/content/repositories/releases -DrepositoryId=releases
Then, to get the file, you should be able to get it directly with the following URL:
wget http://yourserver/nexus/content/repositories/releases/com/you/file/1.0/file-1.0.exe
This is a simple approach to using Nexus as a general artifact repository.
I hope this helps.
The open source version of Nexus (Nexus OSS) is supports many repository formats out of the box including Maven, NuGet, NPM, RubyGems and others. Nexus just runs on Java (e.g. like Jenkins). It is not Java only...
Depending on how you plan to get the DLL files from the repository, different formats might be more or less suited to your usage. You could even use a custom format, but then you rely custom tools.
The scenarios I have seen at many customers are
using a Maven repo and pulling the files in either in a Maven build together with the Maven NAR Plugin (used for native development with C/C++)
using a Maven repo and pulling via plan HTTP GET calls using your scripting language/build tool of choice
using NuGet format and store the DLLs in NuGet packages in the repo and using nuget to retrieve them for the projects
All of these work well.

How can I publish extra meta-artifacts in ivy transparently for developers?

We have the build system, which builds a lot of components. Built components publish their artifacts by ivy in artifactory.
I want to attach an extra meta-artifact to each component during its publication, but transparently for developers. This meta-artifact will contain the information about build-agent, build-log, changelog, etc.
I have access to build agents, so I can:
change some ivy configuration files on build agents
install a customized ivy with a patch on build agents
modify the ivysettings.xml file
I didn’t find any information in ivy documentation. However, I know that there are methods like “options.getExtraArtifacts()” in the ivy source code, so I guess there is a way.
Waiting for your suggestions.
Thanks in advance!
UPD:
I figured out “options.getExtraArtifacts()” serve an "artifact" subtag in a "publish" tag:
https://ant.apache.org/ivy/history/2.4.0/use/publish.html
Option1 : Artifactory Metadata
Are you using Artifactory Pro? I'm not a user myself but the documentation describes a capability to attach arbitrary XML based metadata to any artifact stored in Artifactory. Standalone REST API that should be simple to call from your build:
https://www.jfrog.com/confluence/display/RTF2X/Attaching+and+Reading+Metadata
The big advantage of this approach is that this data is searchable
Option 2: Jenkins plugin
Again I'm not an Artifactory user, but have always been intrigued by this plugin that reportedly delivers tight integration between Jenkins and Artifactory. The relevent bit is the so called "Build info" that is published by the plugin. I would be surprised if this doesn't include some of the info your looking for.
https://wiki.jenkins-ci.org/display/JENKINS/Artifactory+Plugin
Option 3: Attach a custom metadata file
A typical Maven repository has no support for metadata. Both Artifactory and Nexus have bespoke extensions and it appears that in both products this capability is a paid feature...
If all you want to do is store metadata and don't care about the lack of a search interface, then why not simply attach a file containing your metadata as an additional Module file? The following example documents how to do this:
how to publish 3rdparty artifacts with ivy and nexus
Option 4: Ivy extra attributes
This is only an option if you're storing data in an ivy repository (You are more likely using a Maven repo format).
Ivy has the ability to store custom attributes in the ivy module file.
http://ant.apache.org/ivy/history/latest-milestone/concept.html#extra
The following answer describes how these can also be used to influence the layout of your ivy repository.
Dynamically updating Ivy extra attributes

How to easily publish non-Maven artifacts from Jenkins to Bintray?

Is there an easy way to publish non-Maven artifacts to a generic repository on Bintray from a Jenkins job? I've been reading through Deploying Maven and Gradle snapshots to OJO but that applies to Maven-compatible artifacts / Maven repositories only.
I'm aware that I could use the Bintray REST API, but that's a bit too low-level for my taste. I'm wondering if there's something for Jenkins like the Artifactory Plugin, but for use with Bintray.
The closest thing I've found so far is a Bintray REST API wrapper like this Perl module, but I don't like that either as I'd need to install the module on all Jenkins nodes then.
For Bintray, there is Bintray Java Client. We are going to release the new version, which supports file upload and signing in the following week or so.

Maven repositories

We are using maven in the development process. Maven provides a nice feature of configuring the repositories. Using this feature I have created a remote internal repository and I can download the dependencies from that repository.
The development machines are pointing to this remote internal repository. Each development machine has its own local repository(~/.m2/repository/) and hence the dependencies of the project are downloaded from the remote internal repositor**y to the **local repository(~/.m2/repository/) on each developer machine.
Is there any way that the local repository(~/.m2/repository/) on developer machines can be set to the internal remote repository that we have created and which is used for downloading the dependencies from.
If take a look on Maven Introduction to Repositories first paragraph says:
There are strictly only two types of repositories: local and remote.
There is no way how you could change this behavior.
If you would handle that differently it would cause many problems. E.g. build would take much longer because of downloading file all files, IDE would work not work properly (project dependencies would not be stored local), ...
May I suggest another approach to share dependencies and artifacts. In our projects we use nexus as a proxy and repository for our artifacts. It works well with no issues. A basic configuration I already posted here.
After nexus is running you could also setup continous integration using jenkins and enjoy a fully automated environment.
Is your requirement to avoid each developer from having to download all dependencies to his local repository?
Assuming your remote internal repository has the same format as a maven local repository, you can achieve this by adding the following line in the settings.xml of all your developers.
<localRepository>shared-drive-location-of-remote-repository</localRepository>

Resources