Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jfrog.hudson.util;
 
 import  org.jfrog.build.api.BuildRetention;
 
 import java.util.Date;
 import java.util.List;

Author(s):
Tomer Cohen
public class BuildRetentionFactory {

    
Create a Build retention object out of the build

Parameters:
build The build to create the build retention out of
discardOldArtifacts Flag whether to discard artifacts of those builds that are to be discarded.
Returns:
a new Build retention
    public static BuildRetention createBuildRetention(AbstractBuild buildboolean discardOldArtifacts) {
        BuildRetention buildRetention = new BuildRetention(discardOldArtifacts);
        LogRotator rotator = build.getProject().getLogRotator();
        if (rotator == null) {
            return buildRetention;
        }
        if (rotator.getNumToKeep() > -1) {
            buildRetention.setCount(rotator.getNumToKeep());
        }
        if (rotator.getDaysToKeep() > -1) {
            Calendar calendar = Calendar.getInstance();
            calendar.roll(., -rotator.getDaysToKeep());
            buildRetention.setMinimumBuildDate(new Date(calendar.getTimeInMillis()));
        }
        List<StringnotToBeDeleted = ExtractorUtils.getBuildNumbersNotToBeDeleted(build);
        buildRetention.setBuildNumbersNotToBeDiscarded(notToBeDeleted);
        return buildRetention;
    }
New to GrepCode? Check out our FAQ X