Using Jenkins 2.19.2 on Linux.

I'm perplexed by the behavior of my Jenkinsfile, or at least what it's 
reporting to me.  I had it basically working, but then I added some simple 
additional lines to gather some additional information, and now it somehow 
just stops executing the script at some point, without any explanation or 
stack trace.

The following is the method called from a catch block in a stage where I 
first start to see a problem:
@NonCPS
def notifyFailure(String stageName) {
    println 
"result[${currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
    println "SUCCESS[${hudson.model.Result.SUCCESS}]"
    println "was.SUCCESS[${hudson.model.Result.SUCCESS == 
currentBuild.rawBuild.getPreviousBuild()?.getResult()}]"
    try {
        println "About to call bFNMT."
        String    body    = buildFailureNotificationMessageText(stageName)
        println "Returned from bFNMT."
        println "body[${body}]"
    }
    catch (err) {
        err.printStackTrace()
    }
    try {
        String emailAddressesStr = getLastCommitsEmails()
        println "emailAddressesStr[${emailAddressesStr}]"
    }
    catch (err) {
        err.printStackTrace
    }
    def emailAddressesList = emailAddressesStr.split(",")
    println "emailAddressesList[${emailAddressesList}]"
    emailAddressesList.each { address -> println "address[${address}]" }
    def uidsList = emailAddressesList.collect { address -> address.split("@"
)[0] }
    println "uidsList[${uidsList}]"
    sendQMessageToUsers(["dk068x"], body)
    emailext body:body.replaceAll('\\n', '<br>'),
             mimeType:'text/html',
             subject: 'BUILD FAILURE - ' + env.JOB_NAME,
             to: 'dk0...@att.com'
}

The following is the tail of the console output, starting at the first 
println in this method:
result[FAILURE]
[Pipeline] echo
SUCCESS[SUCCESS]
[Pipeline] echo
was.SUCCESS[false]
[Pipeline] echo
About to call bFNMT.
[Pipeline] echo
In bFNMT.
[Pipeline] echo
job[unified-service-layer-build-pipeline] stageName[DEPLOY] bu[http:...]
[Pipeline] echo
In gLCT.
[Pipeline] sh
[workspace] Running shell script
+ git log -5 --date=short '--pretty=format:%cN: %cd : %s'
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[DOSSIER] Response Code: 0
[DOSSIER] Backup file created: /home/jenkins/...
[DOSSIER] Seconds to input data: 0
ERROR: script returned exit code 1
Finished: FAILURE

Here are the two other relevant methods that are called in this sequence:
@NonCPS
def buildFailureNotificationMessageText(String stageName) {
    println "In bFNMT."
    println "job[${env.JOB_NAME}] stageName[${stageName}] 
bu[${env.BUILD_URL}]"
    def result = "${env.JOB_NAME} <b><font color=\"red\">FAILED</font></b> 
(stage ${stageName}).\n" +
                 "\n" +
                 "Last commits:\n" +
                 getLastCommitsText() + "\n" +
                 "\n" +
                 env.BUILD_URL
           
    println "At end of bFNMT."
    return result
}

@NonCPS
def getLastCommitsText() {
    println "In gLCT."
    def result    = sh(returnStdout:true, script:'git log -5 --date=short 
--pretty=format:"%cN: %cd : %s"')
    println "At end of gLCT."
    return result
}

If you look at the console output, you'll see it printed "In gLCT" and then 
it shows the "git log" command line. Then, it just seems to skip the rest 
of the flow and jump to the end of the stage and node.

Also note that this is the "DEPLOY" stage. There was a "BUILD" stage before 
this, that executed similar methods.  It also executed a method that 
executed a "git log" command line, and in the console output I saw the 
first "In ..." message, then the "Running shell script" message followed by 
the "+ git log ..." line, and then just like in the "DEPLOY" stage, it just 
skipped to the end of the stage.  In this case, it went onto the "DEPLOY" 
stage, so this "skipping" behavior didn't cause a failure.

I'm at a loss to understand what this is doing here.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8d2b23ac-e753-448c-a030-d7554eb8fa7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to