Reputation: 3256
I'm using jenkins to build my projects and i can't get the hostname with java
According to this java doc I wrote the follow lines
System.out.println(System.getenv("MACHINE"));
System.out.println(System.getenv("HOSTNAME"));
These are environment variables. BUt the output on build is:
null
null
What I'm doing wrong?
Upvotes: 0
Views: 3002
Reputation: 3256
I solve the problem using the Jenkins Enviromenment Script Plugin
Wiht this plugin I can just run a shell script code and save the values as var to use in the build.
host=$(hostname)
flavor=$(cat /etc/os-release |grep ^'NAME=' |cut -d'=' -f2)
Upvotes: 0