Git Product home page Git Product logo

jenkins-scripts's Introduction

jenkins-scripts

This is a collection of utility scripts for use with Jenkins, the leading continuous integration server.

They can cover a range of use cases - automating Jenkins management, end-user tools, etc. They're organized by function

  • Scriptler scripts, for use in the Jenkins Plugin, are in the "scriptler" directory and should follow the convention as described in scriptler README.md
  • and other scripts are in the "managed-scripts" directory, and then organized by scripting language.

jenkins-scripts's People

Contributors

abayer avatar aheritier avatar avee avatar azmelanar avatar bananeweizen avatar cniweb avatar danielpetisme avatar dohbedoh avatar eciramella avatar edalquist avatar evildethow avatar francisoud avatar gigaaks avatar hayato1980 avatar imod avatar iqwunder avatar kuisathaverat avatar markhu avatar mrdfuse avatar oleg-nenashev avatar rkivisto avatar rpavlik avatar samrocketman avatar schulzh avatar scoheb avatar sschuberth avatar thomasfroehlich avatar thomasleveil avatar toomasr avatar zivry avatar

Stargazers

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

Watchers

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

jenkins-scripts's Issues

Issue in jobExecutedinDateRange.groovy

In the Groovy Script, jobExecutedInDateRange.groovy, in the final output the function job.getLastBuild().getTime(), returns only the last build time of the job.

For example, if I ran a job several times in a day around different timelines, and I add that specific time range in the script, the final output gets al the build but only shows the last Build time of that job for all the build it have retrived.

showJavaVersionUseOnJob.groovy - unable to resolve class AbstractProject

Hi @kuisathaverat ,
thanks for the showJavaVersionUseOnJob.groovy.
Your last improvement https://github.com/jenkinsci/jenkins-scripts/commit/becc030124e9bdf970f2988b48816765e8b614df#diff-64f7974f9841af16622f8c890d273e71 fails to run in scriptler for me:

/scriptler/triggerScript
[(master)]: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script1.groovy: 10: unable to resolve class AbstractProject @ line 10, column 30. if(it instanceof AbstractProject && !it.disabled && it.getJDK()) { ^ 1 error at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:946) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.parse(GroovyShell.java:700) at groovy.lang.GroovyShell.parse(GroovyShell.java:736) at groovy.lang.GroovyShell.parse(GroovyShell.java:727) at org.jenkinsci.plugins.scriptler.util.GroovyScript.call(GroovyScript.java:117) at hudson.remoting.LocalChannel.call(LocalChannel.java:45) at org.jenkinsci.plugins.scriptler.util.ScriptHelper.runScript(ScriptHelper.java:124) at org.jenkinsci.plugins.scriptler.util.ScriptHelper.runScript(ScriptHelper.java:89) at org.jenkinsci.plugins.scriptler.ScriptlerManagement.doTriggerScript(ScriptlerManagement.java:470) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.kohsuke.stapler.Function$InstanceFunction.invoke(Function.java:324) at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:167) at org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse(Function.java:100) at org.kohsuke.stapler.MetaClass$1.doDispatch(MetaClass.java:124) at org.kohsuke.stapler.NameBasedDispatcher.dispatch(NameBasedDispatcher.java:58) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.MetaClass$11.dispatch(MetaClass.java:380) at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:746) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:876) at org.kohsuke.stapler.Stapler.invoke(Stapler.java:649) at org.kohsuke.stapler.Stapler.service(Stapler.java:238) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:135) at com.smartcodeltd.jenkinsci.plugin.assetbundler.filters.LessCSS.doFilter(LessCSS.java:47) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at hudson.plugins.greenballs.GreenBallFilter.doFilter(GreenBallFilter.java:59) at hudson.util.PluginServletFilter$1.doFilter(PluginServletFilter.java:132) at hudson.util.PluginServletFilter.doFilter(PluginServletFilter.java:126) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.csrf.CrumbFilter.doFilter(CrumbFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:84) at hudson.security.UnwrapSecurityExceptionFilter.doFilter(UnwrapSecurityExceptionFilter.java:51) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:117) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter(AnonymousProcessingFilter.java:125) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter(RememberMeProcessingFilter.java:142) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.ui.AbstractProcessingFilter.doFilter(AbstractProcessingFilter.java:271) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at jenkins.security.BasicHeaderProcessor.doFilter(BasicHeaderProcessor.java:93) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter(HttpSessionContextIntegrationFilter.java:249) at hudson.security.HttpSessionContextIntegrationFilter2.doFilter(HttpSessionContextIntegrationFilter2.java:67) at hudson.security.ChainedServletFilter$1.doFilter(ChainedServletFilter.java:87) at hudson.security.ChainedServletFilter.doFilter(ChainedServletFilter.java:76) at hudson.security.HudsonFilter.doFilter(HudsonFilter.java:171) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.compression.CompressionFilter.doFilter(CompressionFilter.java:49) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at hudson.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:82) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter(DiagnosticThreadNameFilter.java:30) at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:143) at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:553) at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:223) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:257) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at winstone.BoundedExecutorService$1.run(BoundedExecutorService.java:77) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

The script runs without issues in: ..jenkins/script.
Do I need to do something additional to get it running with scriptler plugin?
I run Jenkins 2.10

jenkins-scripts/scriptler/jobExecutedInDateRange.groovy

Hi,

Thanks for your script, I tried to execute your script but i am getting result like this multiple times.

SUCCESS Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
FAILURE Tue Jun 15 14:18:43 UTC 2021
SUCCESS Tue Jun 15 14:18:43 UTC 2021
ABORTED Tue Jun 15 14:18:43 UTC 2021
SUCCESS Tue Jun 15 15:36:10 UTC 2021
SUCCESS Tue Jun 15 15:36:10 UTC 2021
SUCCESS Tue Jun 15 15:36:10 UTC 2021

I removed here job name due to security issue, in the above status, when i execute the script, it is showing the same time, same status with multiple times times for a same job. could you please help me to get only one time to get the status for particular time.

Thanks
Madhu

hashifyAllScmTriggers fail on ExternalJob

hashifyAllScmTriggers fail on ExternalJob

ERROR: Build step failed with exception
groovy.lang.MissingMethodException: No signature of method: hudson.model.ExternalJob.getTriggers() is applicable for argument types: () values: []
Possible solutions: getWidgets()
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:55)
    at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
    at jenkins.model.ParameterizedJobMixIn$ParameterizedJob$getTriggers.call(Unknown Source)
    at Script1.run(Script1.groovy:21)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:650)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:636)
    at hudson.plugins.groovy.SystemGroovy.perform(SystemGroovy.java:98)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:534)
    at hudson.model.Run.execute(Run.java:1738)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)
Build step 'Execute system Groovy script' marked build as failure

I'll provide a PR

No signature of method getRoleMap applicable for argument types string

Hello guys,

I am trying to get list of people from the admin role using AuthorizationStrategy.

I have posted a related question on StackOverflow LINK

When I run this code in my Jenkins script console it's complaining about authStrategy.GLOBAL

def roles = authStrategy.getRoleMap(authStrategy.GLOBAL).grantedRoles*.key.name.sort() + authStrategy.getRoleMap(authStrategy.PROJECT).grantedRoles*.key.name.sort()

Versions

  • Jenkins: 2.222.1
  • RoleBasedAuthorizationStrategy: 2.16

Error Output

groovy.lang.MissingMethodException: No signature of method: com.michelin.cio.hudson.plugins.rolestrategy.RoleBasedAuthorizationStrategy.getRoleMap() is applicable for argument types: (java.lang.String) values: [globalRoles]

hashifyAllScmTriggers incompatibility with Jenkins ver. 2.0

https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/hashifyAllScmTriggers.groovy
is incompatible with Jenkins ver. 2.0

ERROR: Build step failed with exception
groovy.lang.MissingPropertyException: No such property: scm for class: org.jenkinsci.plugins.workflow.job.WorkflowJob
Possible solutions: SCMs, ACL, url, name, api
    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_closure4.doCall(Script1.groovy:39)
    at sun.reflect.GeneratedMethodAccessor742.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
    at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
    at org.codehaus.groovy.runtime.callsite.BooleanReturningMethodInvoker.invoke(BooleanReturningMethodInvoker.java:51)
    at org.codehaus.groovy.runtime.callsite.BooleanClosureWrapper.call(BooleanClosureWrapper.java:53)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:4281)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:4153)
    at org.codehaus.groovy.runtime.DefaultGroovyMethods.findAll(DefaultGroovyMethods.java:4138)
    at org.codehaus.groovy.runtime.dgm$202.invoke(Unknown Source)

removeInvalidCredentials incompatibility with Jenkins ver. 2.0

https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/removeInvalidCredentials.groovy
is incompatible with Jenkins ver. 2.0
same as #63

ERROR: Build step failed with exception
groovy.lang.MissingPropertyException: No such property: scm for class: org.jenkinsci.plugins.workflow.job.WorkflowJob
Possible solutions: SCMs, ACL, url, name, api
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53)

Who is the primary maintainer for this project?

I'm curious who the primary maintainer is of this project. If there's not currently a primary maintainer then I would like to volunteer to be the primary maintainer.

If there is already a primary maintainer I would like to be a sub-maintainer and collaborate.

Please let me know.

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.