In this tutorial, I using Jenkins how to start/stop/ status service Postfix mail server. Jenkins the essential for DevOps Roles. Now, let’s go use jenkins start service Postfix mail server.
Note: To start or stop service Postfix then account Jenkins setting in sudoers option “NOPASSWD” as the picture below

How to start service Postfix mail server use Jenkins
Create job “start_stop_postfix” “Freestyle project” as picture below

In General tab, Select “This project is parameterized” with “Choice Parameter” as the picture below

In Build tab, you select “Execute shell” to written bash script “start/stop/status postfix” as the picture below

My code bash script
set +e
f_postfix() {
sudo postfix $1
echo $?
}
whoami
if [ $COMMAND == "status" ]
then
f_postfix $COMMAND
if [ $? -ne 0 ]
then
echo "Postfix not running"
else
echo "Postfix Running"
fi
fi
if [ $COMMAND == "start" ]
then
f_postfix $COMMAND
if [ $? -ne 0 ]
then
echo "Postfix start Not Success"
else
echo "Postfix start Success"
fi
fi
if [ $COMMAND == "stop" ]
then
f_postfix $COMMAND
if [ $? -ne 0 ]
then
echo "Postfix stop Not Success"
else
echo "Postfix stop Success"
fi
fi
The finish, you click “Build with Parameters” to build job. You can select COMMAND “status or start or stop” to Build as the picture below

Conclusion
Thought the article, you can use Jenkins how to start service Postfix mail server as above. I hope will this your helpful. Thank you for reading the DevopsRoles page!

