【问题标题】:How can i launch jenkins in browser automatically with script如何使用脚本在浏览器中自动启动 jenkins
【发布时间】:2018-03-22 07:23:34
【问题描述】:

我已经使用 docker 安装了 Jenkins。尽管我已经跳过了手动设置。 当我构建图像并运行它时(我还有很多事情要做),我需要在浏览器上输入 IP 和端口来打开 Jenkins 仪表板。

我的问题是,我可以使用脚本在 docker 中自动化,当我运行该图像时,构建的 Jenkins 应该在浏览器中打开吗?

任何需要运行的命令请评论

我尝试通过命令打开浏览器,但最终出现错误。 任何人都可以帮助我的自动化工具。

提前谢谢你

【问题讨论】:

  • 您使用的是哪个主机操作系统?
  • 为你工作?如果是的话,它的工作接受它
  • @Adiii 我在 Windows 上工作,基本操作系统是 ubuntu 14.04 .. 实际上我需要动态地做,它应该在不同的系统上工作......帮我这个抱歉迟到的评论,我是仅在您的解决方案上工作:)
  • 检查操作系统并在操作系统上运行不同的命令
  • 实际上我想在不同的 IP 上执行,不同的用户名会尽快尝试更新你.. 谢谢你 @Adiii

标签: linux unix docker jenkins command


【解决方案1】:

转到您的 wifi 信息并获取您的系统。例如,您的主机 IP 是 192.168.1.1 使用 ifconfig or ipconfig 和用户名 whoami 然后在容器内你可以这样做

ssh user_name@192.168.1.1 'DISPLAY=:0 firefox http://192.168.1.1:8080' 基于 linux。

如果主机是窗口,那么你可以运行

ssh user_name@192.168.1.1 'DISPLAY=:0 start http://192.168.1.1:8080'

如果您想避免使用用户名和密码,只需使用公钥-私钥并将您的公钥放在容器中,然后使用该密钥进行 ssh。

docker exec -it container_name ash|bash -c ssh user_name@192.168.1.1 'DISPLAY=:0 firefox http://192.168.1.1:8080'

你可以在操作系统上运行不同的命令

    if [[ "$OSTYPE" == "linux-gnu" ]]; then
        # ...
elif [[ "$OSTYPE" == "darwin"* ]]; then
        # Mac OSX
elif [[ "$OSTYPE" == "cygwin" ]]; then
        # POSIX compatibility layer and Linux environment emulation for Windows
elif [[ "$OSTYPE" == "msys" ]]; then
        # Lightweight shell and GNU utilities compiled for Windows (part of MinGW)
elif [[ "$OSTYPE" == "win32" ]]; then
        # I'm not sure this can happen.
elif [[ "$OSTYPE" == "freebsd"* ]]; then
        # ...
else
        # Unknown.
fi

https://support.rackspace.com/how-to/logging-in-with-an-ssh-private-key-on-linuxmac/

How to detect the OS from a Bash script?

【讨论】:

  • 我需要让它动态化。它应该适用于不同的系统。
猜你喜欢
  • 2014-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-01-24
  • 2016-05-24
  • 2011-08-05
  • 1970-01-01
相关资源
最近更新 更多