Assume I have a file that I generate in my build called: label.txt
I just simply want to publish this to Artifactory. I will even generate the POM for label.txt if need be. But I just can’t seem to figure out how to get it published.
Can someone give me a simple example of this? I am trying to hack my way through this basic scenario with no success. Even tried stuff like this:
configurations {
myConfig
}
// someFile is a reference to the label.txt file that I created
task buildMyNewConfig {
configurations.myConfig.artifacts.add (someFile)
}
task artifactoryPublish.configuration = configurations.myConfig
task artifactoryPublish.doFirst {
buildMyNewConfig
}
But there has to be a simpler way to publish an arbitrary artifact right?
(By the way, I am brand new to gradle so go easy on me.
you can use a task of the type ‘Upload’. The Upload task can be used to upload any configuration. all you need to do is to
Create a customConfiguration (as you already did). 2. Pass the file to the configuration using the artifacts closure. 3. Create and configure your upload task.
I’ve created a tiny sample build file that shows how you can do that:
Note that an ‘Upload’ task is automatically created for each configuration (assuming the ‘base’ plugin has been applied).
If Scott is using the Gradle Artifactory plugin (which provides an ‘artifactoryPublish’ task), it won’t be necessary to create/configure an ‘Upload’ task.
Hello Scott, what problem do you currently have? do you not know which task to execute or does the upload fail? The artifactory plugin adds a task called “artifactoryPublish”. Have a look at http://wiki.jfrog.org/confluence/display/RTF/Gradle+Artifactory+Plugin to see how this task can be configured. My best guess at the moment is, that you have to set the correct configuration in the artifactoryPublish task.
Yeah, I am not sure what task to call. I have called both uploadArchives and artifactoryPublish. They both “succeed”, but no artifact gets put into my artifactory instance. For example, here is what I see:
As a default, the artifactory plugin uses the archives configuration for uploading. As you have applied the java plugin, this archive configuration contains the jar that was created by the jar task and the according pom file. If you want to upload a custom file, you have three options here I think:
Add your custom file to the archives configuration using the snippet Peter provided above. 2. Create a custom configuration for your custom file and add the custom file to this configuration. Then
2.a) replace the configured archives configuration for the artifactoryPublish task by the custom configuration:
Why do you went back to direct REST? How is this communication implemented? It depends on the code you use for http communication where your GETs are put. Can you provide some example code?
def response = http.put (path: pathInRepo,
downloadUri: pathInRepo,
contentType: 'application/zip',
body: file//,
//leave
headers: ['X-Checksum-Deploy':'true','X-Checksum-Sha1':checksum]
)
println 'Attempting to do a GET from: <my artifactory repo>/' + pathInRepo
def getResponse = http.get (path: '<my artifactory repo>/' + pathInRepo
)
So basically, I am “putting” a zip file into artifactory. And then I immediately retrieve it. I am only retrieving it here, because I am trying to figure out where it will get put. I can’t find it though.
The PUT looked like this:
5:40:15.432 [DEBUG] [org.apache.http.headers] >> PUT /artifactory/p4fa-ps5rup3-repo/orc/patches4fa/atgpf/APM_RUP2_Bundle3_13782166/ps5rup3/generic/APM_RUP2_Bundle3_13782166.zip HTTP/1.1
It’s a super long story on what I am trying to do, but I’ll try to give you the background. Today, we have a bunch of zip files. Around 120 or so. The content, filenames, number of artifacts, etc changes all the time. Right now they just sit on an NFS storage area. They are patches delivered by scores of different product teams in my company. We deliver these zip files to our customers. What I want to do is move them from this storage area and into artifactory. I want to take advantage of the ability to stage them into different phases of a release pipeline.
So the gradle build I am playing around with has no compilation or test step. I simply want to crawl this storage area, pick up all the zip files, and get them into Artifactory.
The on the consuming side, I want to be able to retrieve all the zip files and do certain actions on them. This is why I need to know where they get put when they are retrieved.
I would love to take advantage of the buildInfo that artifactory tracks, so that I can know which build copied which zips into artifactory. I don’t seem to get this when using the REST interface. And I am unable to really get any other mechanism going since there is no maven or ivy build here. There are arbitrary artifacts of ever changing size and name. Is there a way to dynamically add them to a configuration and then publish a configuration?
I also was thinking that I could create a “global” pom that tracks all the uploads I did. Then the consumer could just declare a dependency on the signle “global” pom. Since the consumer has no idea on the size, number of files, or names of the files, I figured this was the only way to go.
This publishes an ivy descriptor along to your artifacts. Using ivy makes it easy to reference configurations with lots of zip files in your consuming scripts.
This was very helpful, thank you!!! Is there a way I can control the layout? When I use [module] it ends up using the directory name of the project. I don’t want this. Here is the core of the loop that picks up these artifacts:
Hi guys, any help would be appreciated. I am struggling to understand how I can control the properties related to artifacts in the repository. I have a collection of artifacts that I want organized a certain way.
For example, I want to control the module name. But I can’t figure out how. Gradle seems to always just inject the name of my build directory (in this case p4fa.git).
In general I want to control everything about the layout. Something like this:
For example, I want to control the module name. But I can’t figure out how. Gradle seems to always just inject the name of my build directory (in this case p4fa.git).
Roughly speaking, the module name defaults to the Gradle project name, which defaults to the project directory name.
In general I want to control everything about the layout.
I suppose you want to do a bare-bone upload with full control over the artifacts’ coordinates (group, module, etc.). Once again, here is the link: 44.3.2. File artifacts
The full set of available properties can be found in the Javadoc for ConfigurablePublishArtifact. Apparently, the group can’t be set at this level, but you can set ‘project.group’.