hege 发表于 2018-1-9 23:59:38

jenkins job起停远程slave机器上的系统服务

  目标:jenkins job起停远程slave机器上的系统服务
  问题1: 将jenkins用户加到root和wheel用户组后,执行系统命令时提示输入密码
$ groups
  jenkins root wheel docker
$ systemctl start postfix
  ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
  Authentication is required to manage system services or units.
  Authenticating as: jenkins
  Password:
$ sudo systemctl start postfix
password for jenkins:
  解决办法:
  vi /etc/sudoers
  ## Allows people in group wheel to run all commands
  #%wheel ALL=(ALL)       ALL
  ## Same thing without a password
  %wheelALL=(ALL)       NOPASSWD: ALL
  问题2: jenkins job远程起停服务时报错如下
$ /bin/sh -xe /tmp/jenkins2922363617810746173.sh
  + sudo systemctl start postfix
  sudo: sorry, you must have a tty to run sudo
  解决办法:
  vi /etc/sudoers
  # Defaults    requiretty
  问题1: 将jenkins用户加到root和wheel用户组后,执行系统命令时提示输入密码
$ groups
  jenkins root wheel docker
$ systemctl start postfix
  ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
  Authentication is required to manage system services or units.
  Authenticating as: jenkins
  Password:
$ sudo systemctl start postfix
password for jenkins:
  解决办法:
  vi /etc/sudoers
  ## Allows people in group wheel to run all commands
  #%wheel ALL=(ALL)       ALL
  ## Same thing without a password
  %wheelALL=(ALL)       NOPASSWD: ALL
  问题2: jenkins job远程起停服务时报错如下
$ /bin/sh -xe /tmp/jenkins2922363617810746173.sh
  + sudo systemctl start postfix
  sudo: sorry, you must have a tty to run sudo
  解决办法:
  vi /etc/sudoers
  # Defaults    requiretty
页: [1]
查看完整版本: jenkins job起停远程slave机器上的系统服务