Coder Social home page Coder Social logo

teamclairvoyant / jenkins-workspace-cleanup-groovy-script Goto Github PK

View Code? Open in Web Editor NEW
15.0 6.0 31.0 6 KB

Jenkins Workspace Cleanup script to automate folders clean up for all the jobs

License: MIT License

Groovy 100.00%
workspace jenkins cleanup cleanup-script

jenkins-workspace-cleanup-groovy-script's Introduction

Jenkins Workspace cleanup Groovy Script.

This Groovy script which runs as a separate job in Jenkins that cleans up the folders of a workspace after it is built. It can be integrated with any new or existing job(best used for Maven/gradle builds that occupy a lot of space in workspace folder and is not cleaned). For more detailed steps please visit Link.

jenkins-workspace-cleanup-groovy-script's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jenkins-workspace-cleanup-groovy-script's Issues

Groovy script failed!

Hello, I got an error while running the script, I am using clean-up-all-by-sprint-numbers.groovy.

version info:
Jenkins2.190.3
Groovy Postbuild | org.jvnet.hudson.plugins:groovy-postbuild:2.5

Error running the task:

Groovy script failed:
groovy.lang.MissingPropertyException: No such property: workspace for class: org.jenkinsci.plugins.workflow.job.WorkflowJob
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:66)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:296)
at Script1.run(Script1.groovy:17)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:585)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:623)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:594)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:375)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:312)
at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:406)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
at hudson.model.Build$BuildExecution.post2(Build.java:186)
at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
at hudson.model.Run.execute(Run.java:1841)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)

job object has changed

The workspace object is no longer in the job object. This section

for (job in Jenkins.instance.items)
{
if(job.workspace!=null && job.workspace!="")

returns an error saying that the workspace object cannot be found.

Excellent idea for a cleanup. It would be great to see it work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.