Я создал следующий скрипт groovy для создания образца задания в Jenkins.Jenkins Job DSL Issue
import hudson.model.*
import hudson.node_monitors.*
import hudson.slaves.*
import java.util.concurrent.*
jenkins = Hudson.instance
now=Calendar.instance;
def project_name = 'ARCHIE_DSL_TEST'
println("The build is run at ${now.time}");
freeStyleJob(project_name) {
disabled(false)
logRotator(-1, 10)
description("Our first DSL Generated ServerSpec Job")
parameters {
choiceParam("SERVER_FQDN", ["server1.test.com.au", "server2.test.com.au", "server3.test.com.au", "server4.test.com.au"])
description 'Select a server from the list to test'
}
scm {
git {
remote {
github("MY_ORG/my_repo", 'ssh', 'github.aus.mydomain.com')
branch("*/master")
}
}
}
triggers {
scm("H/15 * * * *")
}
steps {
}
}
Когда я создаю работу в Дженкинс, чтобы запустить этот DSL, он отлично работает и создать работу под названием ARCHIE_DSL_TEST.
Однако то, что я хотел бы сделать, это запустить эту работу с помощью curl, и я выполнил следующую команду.
/usr/bin/curl -k --user 'archie' --data-urlencode "script=$(</var/lib/jenkins/jobs/archie_test/workspace/create_tab.groovy)" https://localhost:8080/scriptText
Однако, это дает мне исключение.
Сборка выполняется в Ср Янв 27 16:54:20 AEDT 2016 groovy.lang.MissingMethodException: Нет подписи метода: Script1.freeStyleJob() не применима для типов аргументов: (java.lang .String, script1 $ _run_closure1) значения: [ARCHIE_DSL_TEST, script1 $ _run_closure1 @ 9761fdb] на org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap (ScriptBytecodeAdapter.java:55) в org.codehaus.groovy.runtime. callsite.PogoMetaClassSite.callCurrent (PogoMetaClassSite.java:78) по адресу org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent (вызов SiteArray.java:46) на org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent (AbstractCallSite.java:133) в org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent (AbstractCallSite.java: 145) на Script1.run (Script1.groovy: 13) при groovy.lang.GroovyShell.evaluate (GroovyShell.java:580) при groovy.lang.GroovyShell.evaluate (GroovyShell.java:618) при заводной. lang.GroovyShell.evaluate (GroovyShell.java:589) в hudson.util.RemotingDiagnostics $ Script.call (RemotingDiagnostics.java:139) в hudson.util.RemotingDiagnostics $ Script.call (RemotingDiagnostics.java:111) на hudson.remoting.LocalChannel.call (L ocalChannel.java:45) при hudson.util.RemotingDiagnostics.executeGroovy (RemotingDiagnostics.java:108) в jenkins.model.Jenkins._doScript (Jenkins.java:3556) в jenkins.model.Jenkins.doScriptText (Jenkins. Java: 3540) в sun.reflect.GeneratedMethodAccessor205.invoke (Unknown Source) в sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) в java.lang.reflect.Method.invoke (Method.java:606) в org.kohsuke.stapler.Function $ InstanceFunction.invoke (Function.java:298) at org.kohsuke.stapler.Function.bindAndInvoke (Function.java:161) в org.kohsuke.stapler.Function.bindAndInvokeAndServeResponse (Function.java:96) at org.kohsuke.stapler.MetaClass $ 1.d oDispatch (MetaClass.java:121) при org.kohsuke.stapler.NameBasedDispatcher.dispatch (NameBasedDispatcher.java:53) в org.kohsuke.stapler.Stapler.tryInvoke (Stapler.java:746) в org.kohsuke. stapler.Stapler.invoke (Stapler.java:876) в org.kohsuke.stapler.Stapler.invoke (Stapler.java:649) по адресу org.kohsuke.stapler.Stapler.service (Stapler.java:238) по адресу javax.servlet.http.HttpServlet.service (HttpServlet.java:848) в org.eclipse.jetty.servlet.ServletHolder.handle (ServletHolder.java:686) на org.eclipse.jetty.servlet.ServletHandler $ CachedChain .doFilter (ServletHandler.java:1494) at hudson.util.PluginServletFilter $ 1.doFilter (PluginServletFilter.Java: 123) на hudson.plugins.greenballs.GreenBallFilter.doFilter (GreenBallFilter.java:59) в hudson.util.PluginServletFilter $ 1.doFilter (PluginServletFilter.java:120) в com.smartcodeltd.jenkinsci. plugin.assetbundler.filters.LessCSS.doFilter (LessCSS.java:46) на hudson.util.PluginServletFilter $ 1.doFilter (PluginServletFilter.java:120) в hudson.plugins.audit_trail.AuditTrailFilter.doFilter (AuditTrailFilter.java : 95) at hudson.util.PluginServletFilter $ 1.doFilter (PluginServletFilter.java:120) at hudson.util.PluginServletFilter.doFilter (PluginServ letFilter.java:114) на org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1482) в hudson.security.csrf.CrumbFilter.doFilter (CrumbFilter.java:48) в орг .eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1482) на hudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:84) в hudson.security.UnwrapSecurityExceptionFilter.doFilter (UnwrapSecurityExceptionFilter. Java: 51) на hudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) на jenkins.security.ExceptionTranslationFilter.doFilter (ExceptionTranslationFilter. Java: 117) на hudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) в org.acegisecurity.providers.anonymous.AnonymousProcessingFilter.doFilter (AnonymousProcessingFilter.java:125) в hudson.security. ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) на org.acegisecurity.ui.rememberme.RememberMeProcessingFilter.doFilter (RememberMeProcessingFilter.java:142) в hudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) по адресу org.acegisecurity.ui.AbstractProcessingFilter.doFilter (AbstractProcessingFilter.java:271) по адресуhudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) на jenkins.security.BasicHeaderProcessor.success (BasicHeaderProcessor.java:140) на jenkins.security.BasicHeaderProcessor.doFilter (BasicHeaderProcessor.java:82) на hudson.security.ChainedServletFilter $ 1.doFilter (ChainedServletFilter.java:87) в org.acegisecurity.context.HttpSessionContextIntegrationFilter.doFilter (HttpSessionContextIntegrationFilter.java:249) в hudson.security.HttpSessionContextIntegrationFilter2.doFilter (HttpSessionContextIntegrationFilter2. java: 67) по адресу hudson.security.ChainedServletFil тер $ 1.doFilter (ChainedServletFilter.java:87) на hudson.security.ChainedServletFilter.doFilter (ChainedServletFilter.java:76) в hudson.security.HudsonFilter.doFilter (HudsonFilter.java:168) в org.eclipse. jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1482) на org.kohsuke.stapler.compression.CompressionFilter.doFilter (CompressionFilter.java:49) в org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1482) на hudson.util.CharacterEncodingFilter.doFilter (CharacterEncodingFilter.java:81) на org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1482) на org.kohsuke.stapler.DiagnosticThreadNameFilter.doFilter (DiagnosticThreadNameFilter.java:30) в org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter (ServletHandler.java:1474) на org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:499) на org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:137) в org.eclipse .jetty.security.SecurityHandler.handle (SecurityHandler.java:533) по адресу org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:231) по адресу org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1086) на org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:428) на org.eclipse.jetty .server.session.SessionHandler.doScope (SessionHandler.java:193) на org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1020) на org.eclipse.jetty.server.handler .ScopedHandler.handle (ScopedHandler.java:135) at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:116) at org.eclipse.jetty.server.Server.handle (Server. java: 370) по адресу org.eclipse.jetty.server.AbstractHttpConnection.handl eRequest (AbstractHttpConnection.java:489) на org.eclipse.jetty.server.AbstractHttpConnection.headerComplete (AbstractHttpConnection.java:949) в org.eclipse.jetty.server.AbstractHttpConnection $ RequestHandler.headerComplete (AbstractHttpConnection.java: 1011) на org.eclipse.jetty.http.HttpParser.parseNext (HttpParser.java:651) на org.eclipse.jetty.http.HttpParser.parseAvailable (HttpParser.java:235) на org.eclipse. jetty.server.AsyncHttpConnection.handle (AsyncHttpConnection.java:82) на org.eclipse.jetty.io.nio.SslConnection.handle (SslConnection.java:196) на org.eclipse.jetty.io .nio.SelectChannelEndPoint.handle (SelectChannelEndPoint.java:668) в org.eclipse.jetty.io.nio.SelectChannelEndPoint $ 1.run (SelectChannelEndPoint.java:52) в winstone.BoundedExecutorService $ 1.Run (BoundedExecutorService.java : 77) на java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1145) на java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:615) в java.lang.Thread .run (Thread.java:745)
Что я здесь делаю неправильно?
Большое спасибо.