Hi I have the following groovy script that I want to use to build a project in Jenkins
#!/usr/bin/env groovy
def deploymentPaths = '[]'
pipeline{
agent {
label 'jenkins-agent'
}
stages{
stage('Build debug'){
steps{
sh './make_debug.sh'
}
}
}
}
How can I make it wait till make_debug finishes and print its output? I tried
#!/usr/bin/env groovy
def deploymentPaths = '[]'
pipeline{
agent {
label 'jenkins-agent'
}
stages{
stage('Build debug'){
steps{
def sout = new StringBuilder(), serr = new StringBuilder()
def proc = './make_debug.sh'.execute()
proc.consumeProcessOutput(sout, serr)
proc.waitForOrKill(10000)
println "out> $sout\nerr> $serr"
}
}
}
}
But this doesn't work. Got following errors:
WorkflowScript: 13: Expected a step @ line 13, column 7.
def sout = new StringBuilder(), serr = new StringBuilder()
^
WorkflowScript: 13: Expected a step @ line 13, column 39.
def sout = new StringBuilder(), serr = new StringBuilder()
^
WorkflowScript: 14: Expected a step @ line 14, column 7.
def proc = './make_debug.sh'.execute()
^
WorkflowScript: 15: Method calls on objects not allowed outside "script" blocks. @ line 15, column 13.
proc.consumeProcessOutput(sout, serr)
^
WorkflowScript: 16: Method calls on objects not allowed outside "script" blocks. @ line 16, column 13.
proc.waitForOrKill(1000)
^
WorkflowScript: 12: Missing required parameter: "delegate" @ line 12, column 5.
step{
^
WorkflowScript: 15: Arguments to "error" must be explicitly named. @ line 15, column 13.
proc.consumeProcessOutput(sout, serr)
^
WorkflowScript: 16: Expecting "class java.lang.String" but got "1000" of type class java.lang.Integer instead @ line 16, column 32.
proc.waitForOrKill(1000)