简体   繁体   中英

Publish project files from Jenkins using Artifactory plugin "Include Patterns"

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 ?

在此处输入图片说明

在此处输入图片说明

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM