Last active
August 10, 2017 05:13
-
-
Save churowa/e250d78d9ee91876849fb77274a0e959 to your computer and use it in GitHub Desktop.
function inside a Jenkinsfile, Jenkins complains that `java.lang.NoSuchMethodError: No such DSL method 'anchor' found among steps`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The expected JSON: | |
{ | |
"text": "Division by zero", | |
"anchor": { | |
"line": "59", | |
"path": "App/FifteenMinuteTest.m" | |
} | |
} | |
*/ | |
import groovy.json.JsonBuilder | |
private String buildJsonCommentFromCompileWarning(warning, baseCodePath) { | |
def fileDetails = warning.file_path.find(/${baseCodePath}.*/) | |
def splitFileDetails = fileDetails.split(":") | |
def line_number = splitFileDetails[1] | |
def file_path = splitFileDetails[0] | |
def reason = warning.reason | |
def builder = new JsonBuilder() | |
def json = builder { | |
text reason | |
anchor { | |
line line_number | |
path file_path | |
} | |
} | |
def payload = builder.toString() | |
echo payload | |
return payload | |
} | |
java.lang.NoSuchMethodError: No such DSL method 'anchor' found among steps [AddInteractivePromotion, ArtifactoryGradleBuild, ArtifactoryMavenBuild, ConanAddRemote, ConanAddUser, InitConanClient..... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I feel like lines 20-26 should give me the json object I want. However, after running my Jenkinsfile, I get the error at the bottom of the gist.
Isn't this the correct syntax for using JsonBuilder?