che
This commit is contained in:
parent
0e9b7bdf9b
commit
b04e21f7d1
|
@ -563,6 +563,13 @@ update
|
|||
render :layout => 'base_projects'
|
||||
end
|
||||
|
||||
def che_request
|
||||
begin
|
||||
work_space_id = Trustie::Che.send()
|
||||
rescue Exception => e
|
||||
raise(e.message)
|
||||
end
|
||||
end
|
||||
|
||||
def revisions
|
||||
@changeset_count = @repository.changesets.count
|
||||
|
|
|
@ -30,9 +30,9 @@
|
|||
<%= link_to "代码分析结果", project_quality_analysis_path(:project_id => @project.id), :class => "btn_zipdown fl ml10" %>
|
||||
<% end %>
|
||||
|
||||
<% if @project.id == 3993 %>
|
||||
<a href="http://106.75.119.131:8080/che/create-from-api-calc-t " target="_blank" class="btn_zipdown fl ml10">CHE环境</a>
|
||||
<% end %>
|
||||
<%# if @project.id == 3993 %>
|
||||
<a href="<%= che_request_project_repositories_path(@project) %>" remote="true" class="btn_zipdown fl ml10">CHE环境</a>
|
||||
<%# end %>
|
||||
|
||||
<div class="fr ">
|
||||
<label class="pro-fenzhi-label fl">克隆网址</label>
|
||||
|
|
|
@ -1092,6 +1092,9 @@ RedmineApp::Application.routes.draw do
|
|||
put 'to_gitlab'
|
||||
# get 'create', :via=>[:get, :post]
|
||||
end
|
||||
collection do
|
||||
get 'che_request'
|
||||
end
|
||||
end
|
||||
|
||||
match 'wiki/index', :via => :get
|
||||
|
|
|
@ -0,0 +1,139 @@
|
|||
#coding=utf-8
|
||||
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
module Trustie
|
||||
module Che
|
||||
def self.send(opt={})
|
||||
begin
|
||||
o = send_to_che()
|
||||
Rails.logger.info("#############send_che_return: #{o}")
|
||||
# if o["code"] != 0
|
||||
# Rails.logger.error "发送che出错: #{o['msg']}"
|
||||
# end
|
||||
return o["id"]
|
||||
rescue => e
|
||||
Rails.logger.error "发送che出错: #{e}"
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def self.send_to_che()
|
||||
#发送地址
|
||||
send_che_uri = URI.parse('http://106.75.119.131:8080')
|
||||
|
||||
params = {
|
||||
"attributes": {
|
||||
},
|
||||
"description": "string",
|
||||
"environments": {
|
||||
"default": {
|
||||
"recipe": {
|
||||
"type": "dockerimage",
|
||||
"content": "eclipse/ubuntu_jdk8"
|
||||
},
|
||||
"machines": {
|
||||
"dev-machine": {
|
||||
"env": {},
|
||||
"servers": {
|
||||
"tomcat8-debug": {
|
||||
"attributes": {},
|
||||
"protocol": "http",
|
||||
"port": "8000"
|
||||
},
|
||||
"codeserver": {
|
||||
"attributes": {},
|
||||
"protocol": "http",
|
||||
"port": "9876"
|
||||
},
|
||||
"tomcat8": {
|
||||
"attributes": {},
|
||||
"protocol": "http",
|
||||
"port": "8080"
|
||||
}
|
||||
},
|
||||
"installers": [
|
||||
"org.eclipse.che.exec",
|
||||
"org.eclipse.che.terminal",
|
||||
"org.eclipse.che.ws-agent",
|
||||
"org.eclipse.che.ls.java"
|
||||
],
|
||||
"volumes": {
|
||||
"m2": {
|
||||
"path": "/home/user/.m2"
|
||||
},
|
||||
"javadata": {
|
||||
"path": "/home/user/jdtls/data"
|
||||
}
|
||||
},
|
||||
"attributes": {
|
||||
"memoryLimitBytes": "2147483648"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"projects": [
|
||||
{
|
||||
"source": {
|
||||
"location": "https://github.com/looly/hutool.git",
|
||||
"type": "git",
|
||||
"parameters": {}
|
||||
},
|
||||
"links": [],
|
||||
"problems": [],
|
||||
"mixins": [
|
||||
"pullrequest"
|
||||
],
|
||||
"name": "hutool",
|
||||
"type": "blank",
|
||||
"path": "/hutool",
|
||||
"attributes": {
|
||||
"contribute_to_branch": [
|
||||
"v4-master"
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"commands": [
|
||||
{
|
||||
"commandLine": "mvn clean install -f ${current.project.path}",
|
||||
"name": "build",
|
||||
"attributes": {
|
||||
"goal": "Build",
|
||||
"previewUrl": ""
|
||||
},
|
||||
"type": "mvn"
|
||||
},
|
||||
{
|
||||
"commandLine": "echo \"hello\"",
|
||||
"name": "newCustom",
|
||||
"attributes": {
|
||||
"goal": "Run",
|
||||
"previewUrl": ""
|
||||
},
|
||||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"defaultEnv": "default",
|
||||
"name": "create-from-api",
|
||||
"links": []
|
||||
}
|
||||
|
||||
http = Net::HTTP.new(send_che_uri.host, send_che_uri.port)
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
http.use_ssl = true
|
||||
begin
|
||||
request = Net::HTTP::Post.new(send_che_uri.request_uri)
|
||||
request.set_form_data(params)
|
||||
request['Content-Type'] = 'application/x-www-form-urlencoded;charset=utf-8'
|
||||
response = http.start { |http| http.request(request) }
|
||||
ActiveSupport::JSON.decode(response.body)
|
||||
rescue =>err
|
||||
Rails.logger.error("#############sendYunpian_error: #{err.message}")
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue