openshift,休息apis二进制部署

问题描述:

我正在关注链接 https://access.redhat.com/documentation/en-US/OpenShift_Enterprise/2/pdf/REST_API_Guide/OpenShift_Enterprise-2-REST_API_Guide-en-US.pdf 来构建我的rest api Java应用程序,该应用程序将从Web位置将WAR二进制文件部署到我的帐户中。openshift,休息apis二进制部署

我正在

InboundJaxrsResponse {上下文= ClientResponse {方法= POST,URI = https://openshift.redhat.com/broker/rest/application/# {myAppID} /部署中,状态= 422,原因=无法处理的实体}}作为响应:

其中# {} myAppID是应用程序的UUID,我在这里更换为安全

我使用GlassFish的REST API和我的一段代码:

String url_of_war = "https://code.google.com/p/web-actions/downloads/detail?name=helloworld.war"; 
    WebTarget webtarget; 
    Client client 
    HostnameVerifier hostnameVerifier = new HostnameVerifier() { 
    @Override 
    public boolean verify(String arg0, SSLSession arg1) { 
    return true; 
    } 
    }; 
    client = ClientBuilder.newBuilder().sslContext(trustAllCertificates()).hostnameVerifier(hostnameVerifier).build(); 
    } 
    URIBuilder uriBuilder = new URIBuilder(); 
    try { 
     uriBuilder = uriBuilder.setScheme("https").setHost("openshift.redhat.com/broker/rest/").setPath("application/#{myAppId}/deployments"); 
     if (getPort() > 0) { 
     uriBuilder = uriBuilder.setPort(getPort()); 
     } 
     URI uri = uriBuilder.build(); 
     webtarget = client.target(uri); 
    } catch (Exception e) { 
     String msg = "Could not build URI!"; 
     throw new RuntimeException(msg, e); 
    } 
    Invocation.Builder invocationBuilder = webtarget.request(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE); 
    invocationBuilder.header("Authorization", "Basic "+Base64.encodeBase64String("#{myuser}:#{mypass}".getBytes())); 
    Form form = new Form(); 
    form.param("hot_deploy", "false"); 
    form.param("force_clean_build", "false"); 
    form.param("artifact_url", URLEncoder.encode(url_of_war, "UTF-8")); 
    Response response = invocationBuilder.post(Entity.form(form));  

我在这里做错了什么,我在这30天内没有线索在线,我也试图创建openshift/jboss兼容的部署文件夹,我放置了战争文件,并提供下载作为copmressed .tar.gz文件,但同样的问题 您的帮助是高度赞赏。 谢谢

+0

纠正,我使用的战争网址是:String url_of_war =“https://web-actions.googlecode.com/files/helloworld.war”; – user2778633

二进制部署需要在一个非常特定的格式,他们不能只是一个战争文件(或压缩战争文件)。

您应该查看关于在OpenShift Online上使用二进制部署的博客文章(https://blog.openshift.com/using-openshift-without-git/)以供进一步参考。我认为这会帮助你让你的代码工作。

+0

谢谢你的回复,其实这是我尝试过的一件事情,我创建了一个部署文件夹结构,因为这个网站提到并把内部的战争作为ROOT.war放在特定的文件夹和tar gz文件夹中,正如我当我手动从rhc部署时,所以生成的二进制文件可手动部署,我可以从我自己的网站作为可下载的lonk,我测试过,但它没有工作 – user2778633