Esempio n. 1
0
 @Override
 public void onCopiedFrom(Item src) {
   super.onCopiedFrom(src);
   synchronized (this) {
     this.nextBuildNumber = 1; // reset the next build number
     this.holdOffBuildUntilSave = true;
   }
 }
Esempio n. 2
0
 @Override
 protected void performDelete() throws IOException, InterruptedException {
   // if a build is in progress. Cancel it.
   RunT lb = getLastBuild();
   if (lb != null) {
     Executor e = lb.getExecutor();
     if (e != null) {
       e.interrupt();
       // should we block until the build is cancelled?
     }
   }
   super.performDelete();
 }
Esempio n. 3
0
  @Override
  public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException {
    super.onLoad(parent, name);

    TextFile f = getNextBuildNumberFile();
    if (f.exists()) {
      // starting 1.28, we store nextBuildNumber in a separate file.
      // but old Hudson didn't do it, so if the file doesn't exist,
      // assume that nextBuildNumber was read from config.xml
      try {
        synchronized (this) {
          this.nextBuildNumber = Integer.parseInt(f.readTrim());
        }
      } catch (NumberFormatException e) {
        // try to infer the value of the next build number from the existing build records. See
        // JENKINS-11563
        File[] folders =
            this.getBuildDir()
                .listFiles(
                    new FileFilter() {
                      public boolean accept(File file) {
                        return file.isDirectory() && file.getName().matches("[0-9]+");
                      }
                    });

        if (folders == null || folders.length == 0) {
          this.nextBuildNumber = 1;
        } else {
          Collection<Integer> foldersInt =
              Collections2.transform(
                  Arrays.asList(folders),
                  new Function<File, Integer>() {
                    public Integer apply(File file) {
                      return Integer.parseInt(file.getName());
                    }
                  });
          this.nextBuildNumber = Collections.max(foldersInt) + 1;
        }
        saveNextBuildNumber();
      }
    } else {
      // From the old Hudson, or doCreateItem. Create this file now.
      saveNextBuildNumber();
      save(); // and delete it from the config.xml
    }

    if (properties == null) // didn't exist < 1.72
    properties = new CopyOnWriteList<JobProperty<? super JobT>>();

    for (JobProperty p : properties) p.setOwner(this);
  }
Esempio n. 4
0
 /** Renames a job. */
 @Override
 public void renameTo(String newName) throws IOException {
   super.renameTo(newName);
 }
Esempio n. 5
0
 @Override
 public synchronized void save() throws IOException {
   super.save();
   holdOffBuildUntilSave = false;
 }