FUNÇÃO DE GERAR PROJETO
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
O mesmo se aplica para a função de Publicação, mudando somente a condição de Mensagem final:
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
Ambas as funções criam um soquete e fazem uma conexão através da porta 13000 do meu servidor de aplicação/repositório. Quando as funções são executadas, retornam uma mensagem para o REDMINE, que por sua vez retorna SUCESSFULL ou ERROR.
O que estou notando é que ao clicar nos botões , ambos estão utilzando os mesmos parâmetros no conceito de RACK:
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"}
e
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"}
Caso precisem de mais algum fonte, estarei aqui.