jenkins - 当使用 “sudo su”时,jenkins通过ssh挂起执行shell

标签 jenkins ssh

字段Exec commandexecute shell over ssh,我只在其中放置了sudo su命令。
但是,当我构建项目时,它总是在sudo su命令处停止直到超时。
The image show what I get in console output.

最佳答案

欢迎使用StackOverflow。

须藤

sudo用于自定义安装,系统文件修改等

交互式 shell (显示器前的人)

当您执行命令 sudo 之前的命令时,此shell将询问您某些特权用户的密码。这个问询事件等待进行用户响应:

enter image description here

后台执行

一些进程,克朗,脚本或诸如jenkins之类的应用程序需要执行 sudo 命令。但是在此模式下,无法输入密码。这是超时的原因

解决方案

  • 禁用requiretty

    https://gist.github.com/jrichardsz/1adaaa07885b45d497b519431701a943

    这种方法的安全风险:

    https://unix.stackexchange.com/a/65789/188975
  • 在Jenkins中使用伪TTY

    https://unix.stackexchange.com/a/373843/188975

  • 关于jenkins - 当使用 “sudo su”时,jenkins通过ssh挂起执行shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52482582/

    相关文章:

    ruby - 我如何获得 PTY.spawn 子退出代码?

    docker - Jenkinsfile 中的 "withRun"和 "inside"有什么区别?

    c# - windows下自动SSH登录

    docker - jenkins-pipeline中DockerBuilderPublisher的cleanupWithJenkinsJobDelete有什么用?

    git - 在 Jenkins 中,如何将项目 check out 到特定目录(使用 GIT)

    python - Elastic Beanstalk 从 shell SSH 连接到 RDS

    python - 在python中获取ftp服务器的ip地址

    linux - 如何在 Shell 脚本中制作 scp 询问我的密码

    jenkins - 这个共享库中的 "not serializable"是什么,我该如何修复它?

    Jenkins : Report results of intermediate [windows batch] build steps in email body