2017-06-12 148 views
0

我試圖通過在初始化Groovy腳本來Artifactory的配置添加到詹金斯設置Artifactory的詹金斯的插件,但是我得到以下錯誤通過Groovy腳本

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.jfrog.hudson.ArtifactoryServer(java.lang.String, java.lang.String, org.jfrog.hudson.util.Credentials, org.jfrog.hudson.util.Credentials, java.lang.Integer, java.lang.Boolean) 

我運行的代碼如下

詹金斯版本:2.46.3 Artifactory的插件版本:2.11.0

import jenkins.model.* 
import org.jfrog.* 
import org.jfrog.hudson.* 
import org.jfrog.hudson.util.Credentials; 

def inst = Jenkins.getInstance() 

def desc = inst.getDescriptor("org.jfrog.hudson.ArtifactoryBuilder") 

def deployerCredentials = new Credentials("admin", "password") 
def resolverCredentials = new Credentials("", "") 

def sinst = [new ArtifactoryServer(
    "server-id", 
    "http://localhost:8081/artifactory", 
    deployerCredentials, 
    resolverCredentials, 
    300, 
    false) 
] 

desc.setArtifactoryServers(sinst) 

回答

0

我正在尋找對同一問題的解決方案,並推斷這一點:

import jenkins.model.* 
import org.jfrog.* 
import org.jfrog.hudson.* 
import org.jfrog.hudson.util.Credentials; 

def inst = Jenkins.getInstance() 

def desc = inst.getDescriptor("org.jfrog.hudson.ArtifactoryBuilder") 

def deployerCredentials = new CredentialsConfig("admin", "password", "") 
def resolverCredentials = new CredentialsConfig("", "", "") 

def sinst = [new ArtifactoryServer(
    "main", 
    "http://localhost:8081/artifactory", 
    deployerCredentials, 
    resolverCredentials, 
    300, 
    false, 
    3) 
] 

desc.setArtifactoryServers(sinst) 

desc.save() 
1

此外,我發現這樣做使用憑證的方式插件

import java.lang.System 
import hudson.model.* 
import jenkins.model.* 
import org.jfrog.* 
import org.jfrog.hudson.* 
import org.jfrog.hudson.util.Credentials; 

def inst = Jenkins.getInstance() 
def artifactoryDesc = inst.getDescriptor("org.jfrog.hudson.ArtifactoryBuilder") 

CredentialsConfig deployerCredentials = new CredentialsConfig(new Credentials("credentialID", "credentialID"), "credentialID", false) 

println "--> Configuring Artifactory... " 
def ArtInst = [new ArtifactoryServer(
    "artifactiory", 
    "https://servername:8443/artifactory", 
    deployerCredentials, 
    null, 
    300, 
    false, 
    3) 
] 

artifactoryDesc.setArtifactoryServers(ArtInst) 
artifactoryDesc.setUseCredentialsPlugin(true) 
artifactoryDesc.save() 
println "--> Configuring Artifactory... done"