pm2-jenkinshook
v1.0.1
Published
receive http hook from jenkins and ask pm2 to reload the application for you
Downloads
4
Maintainers
Readme
Description
PM2 module to receive http webhook from jenkins, execute pre/post hook and gracefull reload the application using pm2. I use this module with the Notification Plugin of jenkins
Install
pm2 install pm2-jenkinshook
Configure
port
(Defaults to8888
) : The port that will be used by the http server to receive hooks.apps
: Contains definition of applications in JSON :{ "APP_NAME" : { "secret" : "ip_of_jenkins", "prehook" : "npm install --production && git submodule update --init", "posthook" : "echo done" } }
APP_NAME
is the name of the api in pm2 and in the url defined on jenkins configuration (eg: :http://127.0.0.1:8888/APP_NAME
).secret
is the ip of the jenkins, since the Notification plugin don't use any kind of authentification, we will stick with the ip.prehook
andposthook
are shell command executed in thecwd
(care of this) of the app before and after making thepullAndGracefullReload
.
How to set these values ?
After having installed the module you have to type :
pm2 set pm2-jenkinshook:key value
To set the apps
option and since its a json string, i advice you to escape it to be sure that the string is correctly set (use this kind of tool).
e.g:
pm2 set pm2-jenkinshook:port 8080
(bind the http server port to 8080)pm2 set pm2-jenkinshook:apps "{\"APP_NAME\":{\"secret\":\"supersecret\",\"prehook\":\"npm install --production && git submodule update --init\",\"posthook\":\"echo done\"}}"
Uninstall
`pm2 uninstall pm2-jenkinshook