Project

General

Profile

project compile plugin

Added by jp qu over 5 years ago

hi everybody,I need develop a plugin which create a "compile" button in redmine project menu,when you touch this button,it will call a shell script which will start to compile the project code,and return a URL,you can find the compile result in this URL.
I already finished the script,I just don't know how to create the compile in redmine,and how to call a shell script in redmine, please help me with that.

Any ideas were helpful,I use mysql and redmine run on the ubuntu14.04,I think it's same way in different redmine version,so if your method worked on any version of redmine,please tell me how to make it work.

A example of shell script was uploaded,you can try with that.

You can also send email to me.
email:

Thanks.


Replies (2)

RE: project compile plugin - Added by Bernhard Rohloff over 5 years ago

Why not creating a script with the existing REST API capabilities and a specific workflow status?
You can create a script to receive issues which were updated in the last couple of minutes and check their status for 'compile' or something like that. If it finds one it compiles your code and sets the status to 'finished' or 'error' and posts the result including the URL as comment to the issue. Let it invoke every let's say 10 minutes by a cron job and Bob's your uncle.

My weapon of choice would be RedminePython which is a great library and does the heavy lifting for you.

Kind regards,

Bernhard

RE: project compile plugin - Added by jp qu over 5 years ago

hi,I think you miss the point which I wanted.
I already modified the sample_plugin for test,I made the compile button in the project menu,and I tried to run shell script to compile the code,now my question is:How to run a shell script in redmine!!!
here is my code which I modified from the sample_plugin,in the file example_controller.rb:
function say_goodbye:

********************
def say_goodbye
find_project
logger.error "run here 0"
logger.error "say_goodbye:@project = #{@project}"
if Herve Harster "3600e"
logger.error "ready to call sh"
exec("/root/call_3600e_build.sh")
end
logger.error "run here 3"
end


when I push compile button,the say_goodbye function will run,I got Herve Harster value,it is 3600e,it should equl and run into if,but it not run into if,so I removed (if Herve Harster "3600e"),just call a shell script with exec,redmine crash and no info in the production.log.

I tried same code in a test.rb which code is:

***********************************
#!/usr/bin/ruby
def say_goodbye
find_project
puts Herve Harster
if Herve Harster == "3600e"
puts "run here2"
exec("/root/call_3600e_build.sh")
end
end

def find_project
puts "run here2"
Herve Harster="3600e"
end

puts "run here0"
say_goodbye


Just run this script,
./test.rb
It is all OK,I don't know why,so please help with that!

Thanks.

    (1-2/2)