how to execute a shell script in build flow "flow" dsl section

1,904 views
Skip to first unread message

niraj nandane

unread,
Oct 15, 2014, 5:48:27 AM10/15/14
to jenkins...@googlegroups.com
I have installed "Build Flow Plugin" and created a build flow project . The commands like build("project-name") are working fine.
I want to execute a shell script which is at /root/niraj/muscript.sh ,which build the system. so i am doing like this
shell(" /root/niraj/muscript.sh") . But it is showing error.
Started by user anonymous
ERROR: Failed to run DSL Script
groovy.lang.MissingMethodException: No signature of method: com.cloudbees.plugins.flow.FlowDelegate.shell() 
is applicable for argument types: (java.lang.String) values: [muscript.sh]

can anyone tell me ? its urgent

Slide

unread,
Oct 15, 2014, 7:57:27 AM10/15/14
to Jenkins User Mailing List
I don't think the build flow supports running a shell script directly, you would need to build() a job that executes the shell script.

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Website: http://earl-of-code.com

niraj nandane

unread,
Oct 15, 2014, 8:47:19 AM10/15/14
to jenkins...@googlegroups.com
Yeah you are right. I have tried that but problem unnessary it is increasing count of total project.

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/DMz2tXSAxlM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Thanks and regards--
Niraj Nandane(Vit pune)

Les Mikesell

unread,
Oct 15, 2014, 8:53:30 AM10/15/14
to jenkinsci-users
On Wed, Oct 15, 2014 at 7:46 AM, niraj nandane <niraj....@gmail.com> wrote:
> Yeah you are right. I have tried that but problem unnessary it is increasing
> count of total project.
>

I think the choices are to use build-flow with separate jobs for every
step the dsl doesn't do directly, or use groovy build steps with your
own code to do what the dsl functions would have done.

--
Les Mikesell
lesmi...@gmail.com

niraj nandane

unread,
Oct 15, 2014, 9:05:16 AM10/15/14
to jenkins...@googlegroups.com
Yeah you are right Les but i am new in field of jenkins.Dont know about groovy at all

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/DMz2tXSAxlM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Les Mikesell

unread,
Oct 15, 2014, 10:37:28 AM10/15/14
to jenkinsci-users
On Wed, Oct 15, 2014 at 8:04 AM, niraj nandane <niraj....@gmail.com> wrote:
> Yeah you are right Les but i am new in field of jenkins.Dont know about
> groovy at all

But you must be doing something relatively complicated to need
build-flow at all. Maybe you should start with what you can't do with
a single ordinary job's build steps or a matrix job if you need
multiple variations of the same build. Build-flow is only needed when
you need to orchestrate some combination of jobs that simple chaining
or a matrix won't handle.

--
Les Mikesell
lesmi...@gmail.com

John VanRyn

unread,
Dec 24, 2015, 8:34:43 AM12/24/15
to Jenkins Users
Here is my buildflow which executes a shell script...
Remember buildflow is DSL which is Groovy..

-----------------------------------
def JobCode = "REL"
def JobName = build.environment.get( "JOB_NAME" )
def BuildURL = build.environment.get( "BUILD_URL" )
def BuildNum = build.environment.get( "BUILD_NUMBER" )
def RevNum = build.environment.get( "GIT_COMMIT" )
def WrkSpce = build.environment.get( "WORKSPACE" )
def svnUrl = build.environment.get( "SVN_URL" )

out.println "Running Build for: "+JobName

def PathToWorkSpace = "jobs/"+JobName+"/workspace/"

def script=WrkSpce+"/Tools/PomVersionUpdater.sh "+JobCode+"-"+RevNum+BuildNum

def executeOnShell(String command) {
return executeOnShell(command, new File(System.properties.'user.dir'))
}

private def executeOnShell(String command, File workingDir) {
println command
def process = new ProcessBuilder(addShellPrefix(command))
.directory(workingDir)
.redirectErrorStream(true)
.start()
process.inputStream.eachLine {println it}
process.waitFor();
return process.exitValue()
}

private def addShellPrefix(String command) {
commandArray = new String[3]
commandArray[0] = "sh"
commandArray[1] = "-c"
commandArray[2] = command
return commandArray
}

executeOnShell(script)

build(JobCode+"-applicant-beans-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-configuration-beans-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-framework-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-security-bld", "PathToWorkSpace": PathToWorkSpace)
parallel (
{
build(JobCode+"-applicant-gateway-ui-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-evaluator-ui-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-configuration-ws-bld", "PathToWorkSpace": PathToWorkSpace)
},
{
build(JobCode+"-applicant-ui-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-management-ui-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-commonservices-bld", "PathToWorkSpace": PathToWorkSpace)
},
{
build(JobCode+"-configuration-ui-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-gateway-ws-bld", "PathToWorkSpace": PathToWorkSpace)
build(JobCode+"-unicas-ws-bld", "PathToWorkSpace": PathToWorkSpace)
}
)
Reply all
Reply to author
Forward
0 new messages