PROJECT GENERATION FUNCTION
def exec_client
begin
hostname = Setting.plugin_gerar_versao_projeto['ip_number']
port = Setting.plugin_gerar_versao_projeto['port_number']
s = TCPSocket.open(hostname, port)
s.puts "MSG_RV"
@project = Project.find_by_identifier(params[:id])
@repositories = @project.repositories
@repository = @repositories.first
if params[:branch] == nil
s.puts @repository.name
else
s.puts params[:branch]
end
msg_final = s.read
puts "MSG_FINAL = #{msg_final}"
if msg_final =~ /MSG_ERR/
display_alert l(:alert_error)
elsif msg_final =~ /MSG_SUC/
display_alert l(:release_done)
end
s.close # Close the socket when done
rescue
display_alert l(:alert_error)
end
end
The same applies to the Publication function, changing only the condition of Final Message:
msg_final = s.read
puts "MSG_FINAL = #{msg_final}"
if msg_final =~ /MSG_ERR/
display_alert l(:alert_error)
elsif msg_final =~ /MSG_SUC/
display_alert l(:publish_done)
end
Both functions create a socket and make a connection through port 13000 of my application server / repository. When the functions are executed, they return a message to REDMINE, which in turn returns SUCESSFULL or ERROR.
What I'm noticing is that by clicking the buttons, both are using the same parameters in the RACK concept:
started POST "/projects/teste/repository/exec_client" for 127.0.0.1 at 2014-02-26 08:44:07 -0300
Processing by RepositoriesController#exec_client as JS
Parameters: {"authenticity_token"=>"ta+3n7z4wGBjnBBaovBAEc9D3oAePYwSLUIhVpciR2c=", "id"=>"teste"}
and
Started POST "/projects/teste/repository/exec_release" for 127.0.0.1 at 2014-02-26 08:43:31 -0300
Processing by RepositoriesController#exec_release as JS
Parameters: {"authenticity_token"=>"ta+3n7z4wGBjnBBaovBAEc9D3oAePYwSLUIhVpciR2c=", "id"=>"teste"}
If you need any more sources, I'll be here.