This commit is contained in:
parent
eb280c1126
commit
c3fa2332c8
|
@ -489,7 +489,7 @@ update
|
|||
|
||||
def che_request
|
||||
begin
|
||||
Trustie::Che.avd()
|
||||
send_to_che
|
||||
rescue Exception => e
|
||||
raise(e.backtrace.join("\n"))
|
||||
end
|
||||
|
|
|
@ -17,6 +17,10 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
module RepositoriesHelper
|
||||
if Rails.env.development?
|
||||
ROOT_PATH="/private/tmp/"
|
||||
|
@ -408,6 +412,124 @@ module RepositoriesHelper
|
|||
end
|
||||
max_space
|
||||
end
|
||||
|
||||
def 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
|
||||
Rails.logger.info("#############info: #{send_che_uri.request_uri}")
|
||||
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
|
||||
|
||||
|
||||
|
|
|
@ -5,14 +5,6 @@ require 'uri'
|
|||
|
||||
module Trustie
|
||||
module Che
|
||||
extend ActiveSupport::Concern
|
||||
module ClassMethods
|
||||
def avd
|
||||
Rails.logger.info("####################che avd start")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.che_send()
|
||||
begin
|
||||
Rails.logger.info("####################che send start")
|
||||
|
|
Loading…
Reference in New Issue