简体   繁体   中英

How can i launch jenkins in browser automatically with script

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM