Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

Build Clean Up Configuration #2502

vart ·
Hi Robin,

I was looking at the demo configuration for the build clean up on your wiki :
http://wiki.pmease.com/display/QB50/Com ... p+Strategy

It looks like the demo configuration that you provided only has a master step , not any other step .. and the master step also doesnot contain anything..

Can you give me somewhat more insight about the implementation of this build clean up configuration?
  • replies 10
  • views 3890
  • stars 0
robinshen ADMIN ·
The demo cleanup configuration responsible for cleaning up builds/artifacts of the demo configuration. The demo cleanup configuration mentioned in wiki is here:
http://demo.pmease.com/settings/128/steps

Its master step runs a script to do the job.
vart ·
Hi ,

Yes.. In saw that groovy script that has been used in the master step .. It deletes all the builds..
Is there some function that can be used that deletes only the build artifacts upto a certain retention period .. and not the build completely ..
vart ·
I saw some classes and methods that i can use under com.pmease.quickbuild.plugin.artifact:
ArtifactCleanupTask.java
ArtifactRetentionPolicy.java
robinshen ADMIN ·
Then for each build, you may get the build artifacts directory by calling:
build.artifactsDir, and then you can go ahead to delete that directory if it exists.
vart ·
and can this build.artifactsdir can anyways be linked to retention somehow based on the number of retention days ..
robinshen ADMIN ·
[quote="vart"]and can this build.artifactsdir can anyways be linked to retention somehow based on the number of retention days ..[/quote]
Not sure what this means. Can you please elaborate?
vart ·
I meant that i need to set my own retention policy first via the groovy script and then delete the artifacts directory ..

this is what i saw has been done in RetainByDays.java :


public class RetainByDays implements ArtifactRetentionPolicy {



private static final long serialVersionUID = 1L;



private String days = "30";



@Editable(name="Days", description="Specify how many days to retain artifacts. Use 0 to retain " +

"all artifacts.")

@Scriptable

@Numeric

@Range(min=0)

@NotEmpty

public String getDays() {

return days;

}



public void setDays(String days) {

this.days = days;

}


Is there a way i can access the date when the build was done and depending upon the x number of days of retention .. i can delete the build artifacts dir ???
robinshen ADMIN ·
Understand. You may check file "ArtifactCleanupTask.java", it contains logic of how to access retain days setting as well as compare it with build date to clean up out-dated artifacts. You may pick necessary part of this file into your groovy script of course.
vart ·
This is what i get

when i try build.getArtifactsDir

system.buildManager.delete(buildToCheck.getArtifactsDir())

groovy.lang.MissingMethodException: No signature of method: com.pmease.quickbuild.entitymanager.impl.DefaultBuildManager$$EnhancerByGuice$$74edc1a9.delete() is applicable for argument types: (java.io.File) values: [/masterdata/Artifacts/Common/_experiments/vpaul1/testconfigvariables/builds/757013/artifacts]
Possible solutions: delete(com.pmease.quickbuild.model.AbstractEntity), delete(com.pmease.quickbuild.model.AbstractEntity), delete(com.pmease.quickbuild.model.Build), delete(com.pmease.quickbuild.model.Build, boolean), delete(com.pmease.quickbuild.model.Configuration, java.lang.String), every()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:54)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:40)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
at org.codehaus.groovy.runti...

any ideas?
robinshen ADMIN ·
system.buildManager.delete(...) expects the build object to be deleted (hence the build record in database as well as all files associated with the build in storage area will be removed all together). If you only want to delete the a directory, try below:
com.pmease.quickbuild.util.FileUtils.delete(build.artifactsDir);