Get Environment Variables from the Job Properties Table

@return All Job Properties with "env." prefix
424562
public Map<String, String> getEnvironmentVariables() {
    final Props props = getJobProps();
    final Map<String, String> envMap = props.getMapByPrefix(ENV_PREFIX);
    return envMap;
  }
1007841
@VisibleForTesting
  Map<String, String> printableJobProperties(Props jobProps) {
    Predicate<String> keyPredicate = new Predicate<String>() {

      @Override
      public boolean apply(String key) {
        if (StringUtils.isEmpty(key)) {
          return true;
        }
        key = key.toLowerCase();
        return !(key.contains("pass") && key.contains("word"));
      }

    };
    return Maps.filterKeys(jobProps.getFlattened(), keyPredicate);
  }
108644
protected List<ExecutableScript> getEnvScripts(String scriptLanguage) {
    Map<String, List<ExecutableScript>> environment = getEnv(scriptLanguage);
    List<ExecutableScript> envScripts = environment.get(scriptLanguage);
    if(envScripts == null) {
      synchronized (this) {
        envScripts = environment.get(scriptLanguage);
        if(envScripts == null) {
          envScripts = initEnvForLanguage(scriptLanguage);
          environment.put(scriptLanguage, envScripts);
        }
      }
    }
    return envScripts;
  }
61708
public Environment getEnvironment()
    {
        if (this.getTask() != null)
        	if (this.getTask().getApplication() instanceof BaseApplication)
        		return ((BaseApplication)this.getTask().getApplication()).getEnvironment();
        return null;
    }
480548
private static Properties getWindowsShellVariables()
        throws EnvironmentException
    {
        Properties properties = new Properties();
        // build the command based on the shell used: cmd.exe or command.com
        StringBuffer buffer = new StringBuffer( getWindowsUserShell() );
        buffer.append( " /C SET" );
        String cmdExec = buffer.toString();

        int exitValue = readEnvironment( cmdExec, properties );
        if( 0 != exitValue )
        {
            String message = "Environment process failed with non-zero exit code of " + exitValue;
            throw new EnvironmentException( message );
        }

        return properties;
    }
699691
@Override
    public void buildEnvironment(Run<?,?> build, EnvVars env) {
        Run run = getRun();
        
        String value = (null == run) ? "UNKNOWN" : Jenkins.getInstance().getRootUrl() + run.getUrl();
        env.put(name, value);

        env.put(name + ".jobName", getJobName());   // undocumented, left for backward compatibility
        env.put(name + "_JOBNAME", getJobName());   // prefer this version

        env.put(name + ".number" , getNumber ());   // same as above
        env.put(name + "_NUMBER" , getNumber ());
        
        // if run is null, default to the standard '#1' display name format
        env.put(name + "_NAME",  (null == run) ? "#" + getNumber() : run.getDisplayName());  // since 1.504

        String buildResult = (null == run || null == run.getResult()) ? "UNKNOWN" : run.getResult().toString();
        env.put(name + "_RESULT",  buildResult);  // since 1.517

        env.put(name.toUpperCase(Locale.ENGLISH),value); // backward compatibility pre 1.345

    }
736551
public static Map<String, String> generateEnvVarsFromData(final Map<String, String> options, final String prefix) {
        if (null == options) {
            return null;
        }
        final HashMap<String, String> envs = new HashMap<String, String>();
        for (final Map.Entry<String, String> entry : options.entrySet()) {
            if (null != entry.getKey() && null != entry.getValue()) {
                envs.put(generateEnvVarName(prefix + "." + entry.getKey()), entry.getValue());
            }
        }
        return envs;
    }
1244570
public static String get() {
		String env = System.getProperty("JOGGER_ENV");
		if (env == null) {
			env = System.getenv("JOGGER_ENV");
		}

		if (env == null) {
			return "dev";
		}

		return env;
	}
160924
public Map<String, String> getEnvProperty() {
		Map<String, String> res = new TreeMap<String, String>();
		MutablePropertySources mps = env.getPropertySources();
        Iterator<PropertySource<?>> iter = mps.iterator();
        while (iter.hasNext()) {
            PropertySource<?> ps = iter.next();
            if (ps instanceof EnumerablePropertySource<?>) {
                for (String propName : ((EnumerablePropertySource<?>) ps).getPropertyNames()) {
                	try {
                		res.put(propName, env.getProperty(propName));
					} catch (Exception e) {
						LOGGER.warn("unresolveable property: " + propName);
						res.put(propName, "UNRESOLVEABLE");
					}
                	
                }
            }
        }
        return res;
	}
825553
public JmxServerBuilder environmentProperties(Properties environmentProperties) {
        HashMap<String, Object> properties = new HashMap<>(environmentProperties.size());
        for (Map.Entry<Object, Object> entry : environmentProperties.entrySet()) {
            properties.put(entry.getKey().toString(), entry.getValue());
        }

        endpoint.getEndpointConfiguration().setEnvironmentProperties(properties);
        return this;
    }
1349124
public @Nonnull List<String> getJobs() {
        List<String> r = new ArrayList<>();
        r.addAll(usages.keySet());
        Collections.sort(r);
        return r;
    }
1135643
@Override
  public synchronized List<JobSpec> getJobs() {
    return Lists.transform(Lists.newArrayList(
        loader.loadPullFilesRecursively(loader.getRootDirectory(), this.sysConfig, shouldLoadGlobalConf())),
        this.converter);
  }
517710
public com.google.protobuf.ByteString
      getEnvBytes() {
    java.lang.Object ref = env_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b = 
          com.google.protobuf.ByteString.copyFromUtf8(
              (java.lang.String) ref);
      env_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }
817373
private Map<String, String> returnEnvironmentVars(AbstractBuild<?, ?> build, TaskListener listener) {
        Map<String, String> envVars = Ghprb.getEnvVars(build, listener);

        if (!envVars.containsKey("ghprbUpstreamStatus")) {
            return null;
        }

        GhprbGitHubAuth auth = GhprbTrigger.getDscp()
                .getGitHubAuth(envVars.get("ghprbCredentialsId"));

        try {
            GitHub gh = auth.getConnection(build.getProject());
            repo = gh.getRepository(envVars.get("ghprbGhRepository"));
            return envVars;
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, "Unable to connect to GitHub repo", e);
            return null;
        }

    }
600646
public java.util.List<Job> getJobs() {
        if (jobs == null) {
            jobs = new com.amazonaws.internal.SdkInternalList<Job>();
        }
        return jobs;
    }
602253
protected ArrayList<EnvLoaderListener> getEnvironmentListeners()
  {
    ArrayList<EnvLoaderListener> listeners;
    listeners = new ArrayList<EnvLoaderListener>();

    /*
    // add the descendant listeners
    if (_childListeners != null) {
      synchronized (_childListenerLock) {
        ClassLoader loader;

        for (loader = this; loader != null; loader = loader.getParent()) {
          if (loader instanceof EnvironmentClassLoader) {
            ArrayList<EnvironmentListener> childListeners;
            childListeners = _childListeners.getLevel(loader);

            if (childListeners != null)
              listeners.addAll(childListeners);
          }
        }
      }
    }
    */

    if (_listeners == null) {
      return listeners;
    }
    
    ArrayList<EnvLoaderListener> envListeners = _listeners;

    if (envListeners != null) {
      synchronized (envListeners) {
        for (int i = 0; i < envListeners.size(); i++) {
          EnvLoaderListener listener = envListeners.get(i);

          if (listener != null)
            listeners.add(listener);
          else {
            envListeners.remove(i);
            i--;
          }
        }
      }
    }
    
    return listeners;
  }
949767
def get_environ(cls, prefix):
        
        return ((key[len(prefix) + 1:], value)
                for key, value in os.environ.items()
                if key.startswith('%s_' % prefix))