Package hudson

Examples of hudson.EnvVars$GetEnvVars


  private String getPomName(AbstractBuild<?, ?> build, BuildListener listener) throws IOException, InterruptedException {
    String pomName;
    MavenModuleSet mavenModuleProject = getMavenProject(build);
    if (mavenModuleProject != null) {
      EnvVars envVars = build.getEnvironment(listener);
      pomName = mavenModuleProject.getRootPOM(envVars);
    } else {
      pomName = getRootPom();
    }
    if (StringUtils.isEmpty(pomName)) {
View Full Code Here


      String value = build.getBuildVariableResolver().resolve(getEnvVar());
      if ("true".equalsIgnoreCase(value)) {
        return Messages.Skipping_Sonar_analysis();
      }
      // check against environment variable
      EnvVars envVars = build.getEnvironment(listener);
      value = new VariableResolver.ByMap<String>(envVars).resolve(getEnvVar());
      if ("true".equalsIgnoreCase(value)) {
        return Messages.Skipping_Sonar_analysis();
      }
    }
View Full Code Here

      return false;
    }

    ArgumentListBuilder args = new ArgumentListBuilder();

    EnvVars env = build.getEnvironment(listener);
    env.overrideAll(build.getBuildVariables());

    SonarRunnerInstallation sri = getSonarRunnerInstallation();
    if (sri == null) {
      args.add(launcher.isUnix() ? "sonar-runner" : "sonar-runner.bat");
    } else {
      sri = sri.forNode(Computer.currentComputer().getNode(), listener);
      sri = sri.forEnvironment(env);
      String exe = sri.getExecutable(launcher);
      if (exe == null) {
        Logger.printFailureMessage(listener);
        listener.fatalError(Messages.SonarRunner_ExecutableNotFound(sri.getName()));
        return false;
      }
      args.add(exe);
      env.put("SONAR_RUNNER_HOME", sri.getHome());
    }
    addTaskArgument(args);
    ExtendedArgumentListBuilder argsBuilder = new ExtendedArgumentListBuilder(args, launcher.isUnix());
    if (!populateConfiguration(argsBuilder, build, listener, env, getSonarInstallation())) {
      return false;
    }

    // Java
    computeJdkToUse(build, listener, env);

    // Java options
    env.put("SONAR_RUNNER_OPTS", getJavaOpts());

    long startTime = System.currentTimeMillis();
    int r;
    try {
      r = executeSonarRunner(build, launcher, listener, args, env);
View Full Code Here

    when(scm.getModuleRoot(eq(workspacePath), any(AbstractBuild.class))).thenReturn(new FilePath(moduleDir));
    when(p.getScm()).thenReturn(scm);
    build = new MyBuild(p);
    build.setWorkspace(workspacePath);
    listener = mock(BuildListener.class);
    env = new EnvVars();
  }
View Full Code Here

   * See SONARPLUGINS-1338
   */
  @Test
  public void build_parameters() throws IOException, InterruptedException {
    AbstractBuild<?, ?> build = mockBuildWithCauses(new TriggersConfig.SonarCause());
    EnvVars env_vars = new EnvVars();
    when(build.getEnvironment(listener)).thenReturn(env_vars);
    Map<String, String> build_vars = new HashMap<String, String>();
    when(build.getBuildVariables()).thenReturn(build_vars);
    assertThat(triggers.isSkipSonar(build, listener)).isNull();
    triggers.setEnvVar("SKIP_SONAR");
View Full Code Here

   * See SONARPLUGINS-1886
   */
  @Test
  public void env_var() throws IOException, InterruptedException {
    AbstractBuild<?, ?> build = mockBuildWithCauses(new TriggersConfig.SonarCause());
    EnvVars env_vars = new EnvVars();
    when(build.getEnvironment(listener)).thenReturn(env_vars);
    Map<String, String> build_vars = new HashMap<String, String>();
    when(build.getBuildVariables()).thenReturn(build_vars);
    assertThat(triggers.isSkipSonar(build, listener)).isNull();
    triggers.setEnvVar("SKIP_SONAR");
    assertThat(triggers.isSkipSonar(build, listener)).isNull();
    env_vars.put("SKIP_SONAR", "true");
    assertThat(triggers.isSkipSonar(build, listener)).isNotNull();
  }
View Full Code Here

      BuildListener listener) {
   
    if (commitSha1 != null && commitSha1.trim().length() > 0) {
      PrintStream logger = listener.getLogger();
      try {
        EnvVars environment = build.getEnvironment(listener);
        return Arrays.asList(environment.expand(commitSha1));
      } catch (IOException e) {
        logger.println("Unable to expand commit SHA value");
        e.printStackTrace(logger);
        return Arrays.asList();
      } catch (InterruptedException e) {
View Full Code Here

        AbstractBuild build = mock(AbstractBuild.class);
        when(build.getAction(MetadataBuildAction.class)).thenReturn(buildAction);

        MetadataEnvironmentContributor contributor = new MetadataEnvironmentContributor();
        EnvVars variables = new EnvVars();
        contributor.buildEnvironmentFor(build, variables, null);
        assertEquals(exposedParentExposed.getValue(), variables.get(exposedParentExposed.getEnvironmentName()));
        assertEquals(notExposedParentExposed.getValue(), variables.get(notExposedParentExposed.getEnvironmentName()));
        assertEquals(exposedParentNotExposed.getValue(), variables.get(exposedParentNotExposed.getEnvironmentName()));
        assertEquals(null, variables.get(notExposedParentNotExposed.getEnvironmentName()));

    }
View Full Code Here

        }

        // Get configured, expanded Android SDK root value
        String androidHome = Utils.expandVariables(build, listener,
                Utils.getConfiguredAndroidHome());
        EnvVars envVars = Utils.getEnvironment(build, listener);

        // Retrieve actual SDK root based on given value
        Node node = Computer.currentComputer().getNode();
        String discoveredAndroidHome = Utils.discoverAndroidHome(launcher, node, envVars,
                androidHome);

        // Get Android SDK object from the given root (or locate on PATH)
        final String androidSdkHome = (envVars != null && keepInWorkspace ? envVars
                .get("WORKSPACE") : null);
        AndroidSdk androidSdk = Utils
                .getAndroidSdk(launcher, discoveredAndroidHome, androidSdkHome);

        // Check whether we should install the SDK
        if (androidSdk == null) {
            PrintStream logger = listener.getLogger();
            if (!shouldInstallSdk) {
                // Couldn't find an SDK, don't want to install it, give up
                log(logger, Messages.SDK_TOOLS_NOT_FOUND());
                return null;
            }

            // Ok, let's download and install the SDK
            log(logger, Messages.INSTALLING_SDK());
            try {
                androidSdk = SdkInstaller.install(launcher, listener, null);
            } catch (SdkInstallationException e) {
                log(logger, Messages.SDK_INSTALLATION_FAILED(), e);
                return null;
            }

            // Check whether anything went wrong
            if (androidSdk == null) {
                log(logger, Messages.SDK_INSTALLATION_FAILED());
                return null;
            }
        }

        // Export environment variables
        final String sdkRoot = androidSdk.getSdkRoot();
        build.addAction(new EnvironmentContributingAction() {

            public void buildEnvVars(AbstractBuild<?, ?> build, EnvVars envVars) {
                if (envVars != null) {
                    envVars.put("ANDROID_HOME", sdkRoot);
                }
            }

            public String getUrlName() {
                return null;
View Full Code Here

   *
   * @throws IOException
   * @throws InterruptedException
   */
  public ProcStarter getProcStarter() throws IOException, InterruptedException {
    final EnvVars buildEnvironment = build.getEnvironment(TaskListener.NULL);
    buildEnvironment.put("ANDROID_ADB_SERVER_PORT", Integer.toString(adbServerPort));
    if (sdk.hasKnownHome()) {
      buildEnvironment.put("ANDROID_SDK_HOME", sdk.getSdkHome());
    }
    if (launcher.isUnix()) {
      buildEnvironment.put("LD_LIBRARY_PATH", String.format("%s/tools/lib", sdk.getSdkRoot()));
    }
    return launcher.launch().stdout(new NullStream()).stderr(logger()).envs(buildEnvironment);
  }
View Full Code Here

TOP

Related Classes of hudson.EnvVars$GetEnvVars

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.