Using Artifactory's REST API to deploy jar file

后端 未结 1 515
说谎
说谎 2021-01-02 19:27

Given this api documentation, how would I use HTTPBuilder and Groovy to construct my query? I\'ve tried multiple things but I\'m not getting it right.

def h         


        
相关标签:
1条回答
  • 2021-01-02 19:53

    The JSON in the mentioned documentation is actually Artifactory's response to the deployment request.
    For deployment, Artifactroy requires only a simple PUT request, for example:

    def restClient = new RESTClient('http://localhost:8080/artifactory/libs-release-local/')
    restClient.auth.basic 'username', 'password'
    restClient.encoder.'application/zip' = this.&encodeZipFile
    def encodeZipFile(Object data) throws UnsupportedEncodingException {
        def entity = new FileEntity((File) data, 'application/zip');
        entity.setContentType('application/zip');
        return entity
    }
    def response = restClient.put(path: 'org/artifact/1.0/artifact-1.0.jar',
          body: new File('/path/to/local/artifact.jar'),
          requestContentType: 'application/zip'
    ) 
    
    0 讨论(0)
提交回复
热议问题