1
votes

In Jenkins (2.7), I've got a simple Maven 3 Java project. It builds and publishes the standard project JAR to Artifactory using Jenkins Artifactory plugin; no issues.

Goal

Now, I need to publish to Artifactory an arbitrary file, deploycfg.yml, alongside the JAR; not in it. So from a repository perspective, it should look like this:

com/acme/sbgroov/1.0.0.7/
-- sbgroov-1.0.0.7.jar
-- sbgroov-1.0.0.7.md5
-- sbgroov-1.0.0.7.sha
-- deploycfg.yml       <---publish this to Artifactory too!

Tried

I've modified the pom to move deploycfg.yml to /target upon building, then tried different configurations for Include Patterns in the Jenkins Artifactory plugin to pick up the files for publishing:

*.jar *.yml
**/*.jar **/*.yml
*.jar deploycfg.yml

The JAR gets published to Artifactory, but not deploycfg.yml. Tried putting the yml file in /target/maven-archiver instead of /target, but that didn't work either. Not sure what else to do at this point, perhaps the starting point for Include Patterns is not what I think it is, /target?

enter image description here

enter image description here

1

1 Answers

1
votes

I was able to do this using a Pipeline Groovy script.

println "Uploading artifacts to Artifactory.  Upload target is: ${uploadTarget}"

def server = Artifactory.server 'artifactory'
def uploadSpec = """{
    "files": [
        {
            "pattern": "target/${pom.artifactId}-${pom.version}.jar",
            "target": "${uploadTarget}/${pom.artifactId}-${pom.version}.jar"
        },
        {
            "pattern": "target/${pom.artifactId}-${pom.version}.war",
            "target": "${uploadTarget}/${pom.artifactId}-${pom.version}.war"
        },
        {
            "pattern": "manifest.yml",
            "target": "${uploadTarget}/manifest.yml"
        }
    ]
}"""

def buildInfo = server.upload(uploadSpec)

// Publish build information.
buildInfo.env.capture = true
server.publishBuildInfo(buildInfo)

However, I ran into the same issue you're having using the traditional Artifactory plugin UI in Jenkins. I'm curious, did you end up figuring it out?