Publish zip artifact

I want to publish zip artifact to artifactory, here is what I am trying to do, building zip:

task makeZip (type: Zip, dependsOn: installApp){
        from('build/install/myApp'){
            into('myApp/')
        }
}

and declare artifact like this:

artifacts {
    archives makeZip
}

I also have the artifactory set up like this:

artifactory {
    contextUrl = "${artifactory_contextUrl}"
       publish {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
    }
}

when I try to publish though with uploadArchives nothing happens. What do I need to change?

The artifactory plugin adds a task named “artifactoryPublish” to your project. Try to use this task instead of uploadArchives.

I used the artifactoryPublish and I see the component in Builds in Artifactory, the problem though it’s not in libs-release-local, I only see build info published.

I specified these variables:

theGroup=com.mycompany
theName=myApp
theVersion=1.0

in gradle.properties

and while the name is picked up, I don’t see it going into the right location - libs-release-local, I only see it in builds tab with the build information, but not the zip file.

ok, I figured it out. I added the following:

changed the artifactory

artifactory {
    contextUrl = "${artifactory_contextUrl}"
 //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
          defaults {
           publications ('mavenZip')
        }
    }
    resolve {
        repository {
            repoKey = 'libs-release-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true
        }
    }
}

notice the defaults section

and made this section:

publishing {
    publications {
        mavenZip(MavenPublication) {
            artifact makeZip{
                classifier "zip"
                extension "zip"
            }
        }
    }
}
1 Like