如何使用脚本自动在浏览器中启动jenkins [英] How can i launch jenkins in browser automatically with script

查看:284
本文介绍了如何使用脚本自动在浏览器中启动jenkins的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have installed Jenkins using docker.Albeit, I have skipped the manual setup. when I build the image and run it(still I have many things to do), I need to type IP and port on my browser to open Jenkins dashboard.

我的问题是,我可以在运行该映像的泊坞窗中使用脚本自动运行构建的Jenkins吗?

任何需要运行的命令都请对其进行注释

any commands need to run please comment it

我试图通过命令打开浏览器,但最终出现错误. 任何人都可以使用我的自动化工具.

I tried to open browser via command, but it end up with error. Anyone help with my automation tool.

提前谢谢

推荐答案

转到您的wifi信息并获取系统.例如,您的主机IP使用ifconfig or ipconfig是192.168.1.1,用户名使用whoami,那么在容器内部您可以像

Go to your wifi information and get your system. For example, your HOST IP is 192.168.1.1 using ifconfig or ipconfig and user name by whoami then inside container you can do like

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 firefox http://192.168.1.1:8080' for linux based.

如果主机是窗口,则可以运行

I f host is window then you can run

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

如果您想避免使用用户名和密码,只需使用公钥-私钥,然后使用该密钥将您的公钥放入容器和ssh中即可.

if you want to avoid username and password just public-private key and place your public key in container and ssh using that key.

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

您可以在os上运行不同的命令

You can run different command base on os

    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//

如何从Bash脚本中检测操作系统? /a>

How to detect the OS from a Bash script?

这篇关于如何使用脚本自动在浏览器中启动jenkins的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆