How can i launch jenkins in browser automatically with script

风流意气都作罢 提交于 2019-12-11 14:49:21

问题


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.

My question is ,can I automate, with the script, in docker that Jenkins which is built should open in the browser when I run that image?

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.

Thank you in advance


回答1:


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

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

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

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/

How to detect the OS from a Bash script?



来源:https://stackoverflow.com/questions/49422804/how-can-i-launch-jenkins-in-browser-automatically-with-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!