How to use environment variables in Jenkins by the Java? -
i trying access environment variables in jenkins through java:
public static webdriver getjenkinsdriver() throws malformedurlexception { desiredcapabilities caps = new desiredcapabilities(); string url = ""; map<string, string> env = system.getenv(); (string envname : env.keyset()) { system.out.format("%s=%s%n", envname, env.get(envname)); } if (system.getenv("selenium_service").equalsignorecase("saucelabs")) { caps.setbrowsername(system.getenv("selenium_browser")); caps.setversion(system.getenv("selenium_version")); caps.setcapability(capabilitytype.platform, system.getenv("selenium_platform")); url = "http://ricardo...saucelabs.com:80/wd/hub"; ... } }
output of command for:
path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:java_home=/usr/lib/jvm/java-8-oracle/:classpath=$java_home/lib/:classpath:path=$java_home/bin/:path:$m2_home=/usr/share/maven/:m2=$m2_home/bin:path=$m2:$path xauthority=/home/ricardoramos/.xauthority xmodifiers=@im=ibus xdg_data_dirs=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/ gdmsession=ubuntu mandatory_path=/usr/share/gconf/ubuntu.mandatory.path textdomaindir=/usr/share/locale/ gtk_im_module=ibus dbus_session_bus_address=unix:abstract=/tmp/dbus-jqr3phzwn6 defaults_path=/usr/share/gconf/ubuntu.default.path xdg_current_desktop=unity swt_gtk3=0 upstart_session=unix:abstract=/com/ubuntu/upstart-session/1000/2230 qt4_im_module=ibus session_manager=local/falcon:@/tmp/.ice-unix/2511,unix/falcon:/tmp/.ice-unix/2511 logname=ricardoramos job=dbus pwd=/home/ricardoramos im_config_phase=1 language=pt_br:pt:en shell=/bin/bash ...
but when enter if condition displayed message of nullpointerexception, set jenkins follows:
must declare environment variables @ end of .bashrc file or jenkins himself smart enough share these variables of "global properties" operating system?
Comments
Post a Comment