Checks the correctness of the newBuildsDirValue for use as {@link #buildsDir}.
@param newBuildsDirValue the candidate newBuildsDirValue for updating {@link #buildsDir}.
196762
@VisibleForTesting
    /*private*/ static void checkRawBuildsDir(String newBuildsDirValue) throws InvalidBuildsDir {

        // do essentially what expandVariablesForDirectory does, without an Item
        String replacedValue = expandVariablesForDirectory(newBuildsDirValue,
                                                           "doCheckRawBuildsDir-Marker:foo",
                                                           Jenkins.getInstance().getRootDir().getPath() + "/jobs/doCheckRawBuildsDir-Marker$foo");

        File replacedFile = new File(replacedValue);
        if (!replacedFile.isAbsolute()) {
            throw new InvalidBuildsDir(newBuildsDirValue + " does not resolve to an absolute path");
        }

        if (!replacedValue.contains("doCheckRawBuildsDir-Marker")) {
            throw new InvalidBuildsDir(newBuildsDirValue + " does not contain ${ITEM_FULL_NAME} or ${ITEM_ROOTDIR}, cannot distinguish between projects");
        }

        if (replacedValue.contains("doCheckRawBuildsDir-Marker:foo")) {
            // make sure platform can handle colon
            try {
                File tmp = File.createTempFile("Jenkins-doCheckRawBuildsDir", "foo:bar");
                tmp.delete();
            } catch (IOException e) {
                throw new InvalidBuildsDir(newBuildsDirValue +  " contains ${ITEM_FULLNAME} but your system does not support it (JENKINS-12251). Use ${ITEM_FULL_NAME} instead");
            }
        }

        File d = new File(replacedValue);
        if (!d.isDirectory()) {
            // if dir does not exist (almost guaranteed) need to make sure nearest existing ancestor can be written to
            d = d.getParentFile();
            while (!d.exists()) {
                d = d.getParentFile();
            }
            if (!d.canWrite()) {
                throw new InvalidBuildsDir(newBuildsDirValue +  " does not exist and probably cannot be created");
            }
        }
    }
53343
public RunList<R> newBuilds() {
        GregorianCalendar cal = new GregorianCalendar();
        cal.add(Calendar.DAY_OF_YEAR, -7);
        final long t = cal.getTimeInMillis();

        // can't publish on-going builds
        return filter(new Predicate<R>() {
            public boolean apply(R r) {
                return !r.isBuilding();
            }
        })
        // put at least 10 builds, but otherwise ignore old builds
        .limit(new CountingPredicate<R>() {
            public boolean apply(int index, R r) {
                return index < 10 || r.getTimeInMillis() >= t;
            }
        });
    }
1018579
private static void runBuild(@Nonnull IProject myProject) {
        StructuredSelection selection = new StructuredSelection(myProject);
        FindBugsAction action = new FindBugsAction();
        action.selectionChanged(null, selection);
        action.run(null);
    }
358601
private void handleArgBuildFile(final Deque<String> args) {
        final String value = args.pop();
        if (value == null) {
            throw new BuildException("You must specify a buildfile when using the --buildfile argument");
        }
        buildFile = new File(value.replace('/', File.separatorChar));
    }
944986
public void setBuilds(java.util.Collection<Build> builds) {
        if (builds == null) {
            this.builds = null;
            return;
        }

        this.builds = new java.util.ArrayList<Build>(builds);
    }
633970
@JavaScriptMethod
    @SuppressWarnings({"UnusedDeclaration"})
    public LoadBuildsResponse loadBuild(String buildId) {
        LoadBuildsResponse response = new LoadBuildsResponse();
        // When we load a new build we need also to reset the promotion plugin.
        // The null plugin is related to 'None' plugin.
        setPromotionPlugin(null);
        try {
            this.currentPromotionCandidate = promotionCandidates.get(buildId);
            if (this.currentPromotionCandidate == null) {
                throw new IllegalArgumentException("Can't find build by ID: " + buildId);
            }
            List<String> repositoryKeys = getRepositoryKeys();
            List<UserPluginInfo> plugins = getPromotionsUserPluginInfo();
            PromotionConfig promotionConfig = getPromotionConfig();
            String defaultTargetRepository = getDefaultPromotionTargetRepository();
            if (StringUtils.isNotBlank(defaultTargetRepository) && repositoryKeys.contains(defaultTargetRepository)) {
                promotionConfig.setTargetRepo(defaultTargetRepository);
            }
            response.addRepositories(repositoryKeys);
            response.setPlugins(plugins);
            response.setPromotionConfig(promotionConfig);
            response.setSuccess(true);
        } catch (Exception e) {
            response.setResponseMessage(e.getMessage());
        }
        return response;
    }
352363
protected void updateBuild(Build value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleElement(innerCount, root, "sourceDirectory", value.getSourceDirectory(), null);
         findAndReplaceSimpleElement(innerCount, root, "scriptSourceDirectory", value.getScriptSourceDirectory(),
                  null);
         findAndReplaceSimpleElement(innerCount, root, "testSourceDirectory", value.getTestSourceDirectory(), null);
         findAndReplaceSimpleElement(innerCount, root, "outputDirectory", value.getOutputDirectory(), null);
         findAndReplaceSimpleElement(innerCount, root, "testOutputDirectory", value.getTestOutputDirectory(), null);
         iterateExtension(innerCount, root, value.getExtensions(), "extensions", "extension");
         findAndReplaceSimpleElement(innerCount, root, "defaultGoal", value.getDefaultGoal(), null);
         iterateResource(innerCount, root, value.getResources(), "resources", "resource");
         iterateResource(innerCount, root, value.getTestResources(), "testResources", "testResource");
         findAndReplaceSimpleElement(innerCount, root, "directory", value.getDirectory(), null);
         findAndReplaceSimpleElement(innerCount, root, "finalName", value.getFinalName(), null);
         findAndReplaceSimpleLists(innerCount, root, value.getFilters(), "filters", "filter");
         updatePluginManagement(value.getPluginManagement(), "pluginManagement", innerCount, root);
         iteratePlugin(innerCount, root, value.getPlugins(), "plugins", "plugin");
      } // end if
   }
1310159
public void setBuiltInDeliveryRateType(com.google.api.ads.admanager.axis.v201805.DeliveryRateType builtInDeliveryRateType) {
        this.builtInDeliveryRateType = builtInDeliveryRateType;
    }
1327525
private void upgradeIfNeeded(File oldPidGenDir) throws IOException {
        if (oldPidGenDir != null && oldPidGenDir.isDirectory()) {
            String[] names = oldPidGenDir.list();
            Arrays.sort(names);
            if (names.length > 0) {
                BufferedReader in =
                        new BufferedReader(new InputStreamReader(new FileInputStream(new File(oldPidGenDir,
                                                                                              names[names.length - 1]))));
                String lastLine = null;
                String line;
                while ((line = in.readLine()) != null) {
                    lastLine = line;
                }
                in.close();
                if (lastLine != null) {
                    String[] parts = lastLine.split("|");
                    if (parts.length == 2) {
                        neverGeneratePID(parts[0]);
                    }
                }
            }
        }
    }
512742
public void putBuildRow(BaseRow row) throws IOException {
		final int hashCode = hash(this.buildSideProjection.apply(row).hashCode(), 0);
		// TODO: combine key projection and build side conversion to code gen.
		insertIntoTable(originBuildSideSerializer.baseRowToBinary(row), hashCode);
	}
120136
protected static void checkDirectory(boolean generateSouceOnly, File sourceOutputDir) {
        if (generateSouceOnly) {
            if (sourceOutputDir == null) {
                throw new RuntimeException("param 'sourceOutputDir' is null.");
            }

            if (!sourceOutputDir.isDirectory()) {
                throw new RuntimeException("param 'sourceOutputDir' should be a exist file directory.");
            }
        }
    }
1303703
public void putBuildRow(BinaryRow row) throws IOException {
		long key = getBuildLongKey(row);
		final int hashCode = hashLong(key, 0);
		insertIntoTable(key, hashCode, row);
	}
445575
public static void newBuilder(String projectId, String topicId) throws Exception {
    ProjectTopicName topic = ProjectTopicName.of(projectId, topicId);
    Publisher publisher = Publisher.newBuilder(topic).build();
    try {
      // ...
    } finally {
      // When finished with the publisher, make sure to shutdown to free up resources.
      publisher.shutdown();
      publisher.awaitTermination(1, TimeUnit.MINUTES);
    }
  }
189784
public void addExtraBuild(ModuleBuildFuture future) {
		if (extraBuilds == null) {
			extraBuilds = new LinkedList<ModuleBuildFuture>();
		}
		extraBuilds.add(future);
	}
680517
public static boolean containsBuildCase(final Annotation anno, final BuildCase buildCase) {
        
        Objects.requireNonNull(anno);
        Objects.requireNonNull(buildCase);
        
        final Optional<BuildCase[]> attrCases = getAnnotationAttribute(anno, "cases", BuildCase[].class);
        if(attrCases.isPresent()) {
            final BuildCase[] casesValue = attrCases.get();
            if(casesValue.length == 0) {
                // 値が空の配列の場合
                return true;
            }
            
            for(BuildCase value : casesValue) {
                if(value == buildCase) {
                    return true;
                }
            }
            
            return false;
        }
        
        // 属性を持たない場合
        return true;
    }
214182
protected void addToBuildSpec(String builderID) throws CoreException {
        IProjectDescription description = getProject().getDescription();
        ICommand findBugsCommand = getFindBugsCommand(description);
        if (findBugsCommand == null) {
            // Add a Java command to the build spec
            ICommand newCommand = description.newCommand();
            newCommand.setBuilderName(builderID);
            setFindBugsCommand(description, newCommand);
        }
    }
611556
private void addNewBuilds(List<BambooJob> enabledJobs,
                              Map<BambooJob, Set<Build>> buildsByJob) {
        long start = System.currentTimeMillis();
        int count = 0;

        for (BambooJob job : enabledJobs) {
            if (job.isPushed()) {
                LOG.info("Job Pushed already: " + job.getJobName());
                continue;
            }
            // process new builds in the order of their build numbers - this has implication to handling of commits in BuildEventListener
            ArrayList<Build> builds = Lists.newArrayList(nullSafe(buildsByJob.get(job)));
            builds.sort((Build b1, Build b2) -> Integer.valueOf(b1.getNumber()) - Integer.valueOf(b2.getNumber()));
            for (Build buildSummary : builds) {
                if (isNewBuild(job, buildSummary)) {
                    Build build = bambooClient.getBuildDetails(buildSummary
                            .getBuildUrl(), job.getInstanceUrl());
                    if (build != null) {
                        build.setCollectorItemId(job.getId());
                        buildRepository.save(build);
                        count++;
                    }
                }
            }
        }
        log("New builds", start, count);
    }