Continuous integration 上载到船头CI中的密码时,消息头值中存在非法字符
我有我的Kotlin项目的jacoco代码覆盖率报告,我正在上传到Codacy 我正在使用codacy coverage reporter 7.1.0并使用以下gradle任务上载报告Continuous integration 上载到船头CI中的密码时,消息头值中存在非法字符,continuous-integration,code-coverage,codacy,Continuous Integration,Code Coverage,Codacy,我有我的Kotlin项目的jacoco代码覆盖率报告,我正在上传到Codacy 我正在使用codacy coverage reporter 7.1.0并使用以下gradle任务上载报告 task("uploadTestCoverageReportToCodacy", JavaExec::class) { dependsOn("codeCoverageReport") main = "com.codacy.CodacyCoverag
task("uploadTestCoverageReportToCodacy", JavaExec::class) {
dependsOn("codeCoverageReport")
main = "com.codacy.CodacyCoverageReporter"
classpath = codacy
args = arrayListOf(
"report",
"-l",
"Kotlin",
"-r",
"$buildDir/reports/jacoco/jacocoTestReport.xml")
}
“codeCoverageReport”任务已成功完成,并且我已在我的船头CI中配置了CODACY_PROJECT_令牌
我面临的问题是以下信息:
Exception in thread "main" java.lang.IllegalArgumentException: Illegal character(s) in message header value: <CODACY_PROJECT_TOKEN> (the token value)
at java.base/sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:559)
at java.base/sun.net.www.protocol.http.HttpURLConnection.isExternalMessageHeaderAllowed(HttpURLConnection.java:494)
at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3174)
at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:312)
at scalaj.http.HttpRequest.$anonfun$doConnection$3(Http.scala:359)
at scalaj.http.HttpRequest.$anonfun$doConnection$3$adapted(Http.scala:358)
at scala.collection.immutable.List.foreach(List.scala:392)
at scalaj.http.HttpRequest.doConnection(Http.scala:358)
at scalaj.http.HttpRequest.exec(Http.scala:343)
at scalaj.http.HttpRequest.asString(Http.scala:491)
at com.codacy.api.client.CodacyClient.post(CodacyClient.scala:71)
at com.codacy.api.service.CoverageServices.postRequest(CoverageServices.scala:91)
at com.codacy.api.service.CoverageServices.sendReport(CoverageServices.scala:27)
at com.codacy.rules.ReportRules.sendReport(ReportRules.scala:128)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$8(ReportRules.scala:54)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$7(ReportRules.scala:53)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$6(ReportRules.scala:52)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$4(ReportRules.scala:51)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$3(ReportRules.scala:50)
at scala.collection.immutable.List.map(List.scala:286)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$2(ReportRules.scala:47)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.$anonfun$codacyCoverage$1(ReportRules.scala:40)
at com.codacy.rules.ReportRules.$anonfun$withCommitUUID$4(ReportRules.scala:267)
at com.codacy.rules.ReportRules.$anonfun$withCommitUUID$4$adapted(ReportRules.scala:267)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.rules.ReportRules.withCommitUUID(ReportRules.scala:267)
at com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:35)
at com.codacy.CodacyCoverageReporter$.$anonfun$sendReport$1(CodacyCoverageReporter.scala:41)
at scala.util.Either.flatMap(Either.scala:341)
at com.codacy.CodacyCoverageReporter$.sendReport(CodacyCoverageReporter.scala:33)
at com.codacy.CodacyCoverageReporter$.run(CodacyCoverageReporter.scala:18)
at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:13)
at com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:11)
at caseapp.CommandAppWithPreCommand.$anonfun$main$1(CommandAppWithPreCommand.scala:97)
at caseapp.CommandAppWithPreCommand.$anonfun$main$1$adapted(CommandAppWithPreCommand.scala:82)
at scala.Option.foreach(Option.scala:407)
at caseapp.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:82)
at com.codacy.CodacyCoverageReporter.main(CodacyCoverageReporter.scala)
线程“main”java.lang.IllegalArgumentException中的异常:消息头值中的非法字符:(令牌值)
位于java.base/sun.net.www.protocol.http.HttpURLConnection.checkMessageHeader(HttpURLConnection.java:559)
位于java.base/sun.net.www.protocol.http.HttpURLConnection.isexternalMessageHeaderLowed(HttpURLConnection.java:494)
位于java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestProperty(HttpURLConnection.java:3174)
位于java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestProperty(HttpsURLConnectionImpl.java:312)
在scalaj.http.HttpRequest.$anonfun$doConnection$3(http.scala:359)
在scalaj.http.HttpRequest.$anonfun$doConnection$3$adapted(http.scala:358)
位于scala.collection.immutable.List.foreach(List.scala:392)
位于scalaj.http.HttpRequest.doConnection(http.scala:358)
位于scalaj.http.HttpRequest.exec(http.scala:343)
位于scalaj.http.HttpRequest.asString(http.scala:491)
位于com.codacy.api.client.CodacyClient.post(CodacyClient.scala:71)
位于com.codacy.api.service.CoverageServices.postRequest(CoverageServices.scala:91)
位于com.codacy.api.service.CoverageServices.sendReport(CoverageServices.scala:27)
在com.codacy.rules.ReportRules.sendReport(ReportRules.scala:128)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$8(ReportRules.scala:54)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$7(ReportRules.scala:53)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$6(ReportRules.scala:52)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$4(ReportRules.scala:51)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$3(ReportRules.scala:50)
位于scala.collection.immutable.List.map(List.scala:286)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$2(ReportRules.scala:47)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.$anonfun$codacyCoverage$1(ReportRules.scala:40)
在com.codacy.rules.ReportRules.$anonfun$withcommituid$4(ReportRules.scala:267)
在com.codacy.rules.ReportRules.$anonfun$withcommituid$4$adapted(ReportRules.scala:267)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.rules.ReportRules.WithCommitUID(ReportRules.scala:267)上
在com.codacy.rules.ReportRules.codacyCoverage(ReportRules.scala:35)
在com.codacy.codacoveragereporter$.$anonfun$sendReport$1(codacoveragereporter.scala:41)
在scala.util.other.flatMap(other.scala:341)
在com.codacy.CodacyCoverageReporter$.sendReport上(CodacyCoverageReporter.scala:33)
位于com.codacy.CodacyCoverageReporter$.run(CodacyCoverageReporter.scala:18)
位于com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:13)
位于com.codacy.configuration.parser.ConfigurationParsingApp.run(ConfigurationParser.scala:11)
在caseapp.CommandAppWithPreCommand.$anonfun$main$1(CommandAppWithPreCommand.scala:97)
在caseapp.CommandAppWithPreCommand.$anonfun$main$1$adapted(CommandAppWithPreCommand.scala:82)
位于scala.Option.foreach(Option.scala:407)
在caseapp.CommandAppWithPreCommand.main(CommandAppWithPreCommand.scala:82)
位于com.codacy.CodacyCoverageReporter.main(CodacyCoverageReporter.scala)
我已经仔细检查了codacy标记是否正确,并且没有任何前导或尾随空格或任何奇怪的字符
有人知道为什么上传到密码会有这个问题吗?请注意,此gradle任务在本地计算机中运行良好,但它在CI中产生问题。CI正在使用新行注入令牌。我用以下方法解决了这个问题:
task("uploadTestCoverageReportToCodacy", JavaExec::class) {
dependsOn("codeCoverageReport")
main = "com.codacy.CodacyCoverageReporter"
classpath = codacy
args = arrayListOf(
"report",
"-t",
System.getenv("CODACY_PROJECT_TOKEN")?.trim() ?: "",
"-l",
"Kotlin",
"-r",
"$buildDir/reports/jacoco/jacocoTestReport.xml")
}