Restarting apache with Jenkins or Phing

怎甘沉沦 提交于 2019-12-05 12:16:39
Tom Jowitt

If you're on Linux you can run Phing with the sudo command to allow it enough privileges to restart apache.

sudo phing restartapache

Assuming that restartapache is an exec task that calls the apache restart command. Eg:

<target name="restartapache" description="Restarts the web server">
    <exec command="/etc/init.d/apache2 restart" />
</target>  

To avoid the sudo command prompting for a password you can update your sudo permissions for whatever user account you are running your build under (this example demonstrates turning off the sudo password prompt for the jenkins user):

sudo visudo

Then add the following lines:

Defaults:jenkins !requiretty,!lecture
jenkins ALL=NOPASSWD:/etc/init.d/apache2

The above has been edited to improve security according to this answer so that Jenkins is only allowed to restart apache without a password and nothing else.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!