当前位置: 首页 > 知识库问答 >
问题:

jenkins管道脚本有问题。没有适用于参数类型的方法签名:(Java . lang . string)values[string]

贡俊
2023-03-14

我有类电子邮件,其中包含loginAndEmail依赖方法:

class Emails{
 static List<String> loginEmaildependency (String login){
  Map<String, String> result = new HashMap<>()
  result.put("abc", "abc@gmail.com")
  result.put("cde", "cde@gmail.com")
  ....
  ....
  if(result.get(login.toLowerCase()) != null){
   return [result.get(login.toLowerCase())]
  }
  else {return ["xxx@gmail.com"]}
 }
}

我还有 2 个管道脚本:

BuildEmailExt email = null
            if (env.JOB_NAME =~ /TEST-/ || env.JOB_NAME =~ /test-/) {

                def userLogin = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()

                email = new BuildEmailExt(this, Emails.loginEmailDependency(userLogin.toString()))
                    .jobParams(["gitRepoName"         : env.gitRepoName,
                                "gitBranch  "         : env.gitBranch,
                                "skipInstallationTest": env.skipInstallationTest,
                                "skipDeployNexus"     : env.skipDeployNexus,
                                "dockerImageMq"       : dockerImageMq,
                                "dockerImageWas"      : dockerImageWas,
                                "dockerImageDb"       : dockerImageDb])
            } else {
              email = new BuildEmailExt(this, Emails.repoRecipientEmails(gitRepoName))
                    .jobParams(["gitBranch"      : env.gitBranch,
                                "skipGuiTest"    : env.skipGuiTest,
                                "skipDeployNexus": env.skipDeployNexus,
                                "forceWasInstall": env.forceWasInstall,
                                "dockerImageMq"  : dockerImageMq,
                                "dockerImageWas" : dockerImageWas,
                                "dockerImageDb"  : dockerImageDb])
            }


if (env.JOB_NAME =~ /TEST-/ || env.JOB_NAME =~ /test-/) {

            def userLogin = currentBuild.rawBuild.getCause(Cause.UserIdCause).getUserId()

            email = new BuildEmailExt(this, Emails.loginEmailDependency(userLogin.toString()))
                .jobParams(["gitRepoName"         : env.gitRepoName,
                            "gitBranch  "         : env.gitBranch,
                            "skipInstallationTest": env.skipInstallationTest,
                            "skipDeployNexus"     : env.skipDeployNexus,
                            "dockerImageMq"       : dockerImageMq,
                            "dockerImageWas"      : dockerImageWas,
                            "dockerImageDb"       : dockerImageDb])
        } else {
            email = new BuildEmailExt(this, Emails.Teams())
                .jobParams(["gitBranch"      : env.gitBranch,
                            "skipGuiTest"    : env.skipGuiTest,
                            "skipDeployNexus": env.skipDeployNexus,
                            "forceWasInstall": env.forceWasInstall,
                            "dockerImageMq"  : dockerImageMq,
                            "dockerImageWas" : dockerImageWas,
                            "dockerImageDb"  : dockerImageDb])
        }

在第二个脚本中,我使用这个脚本并且所有工作都成功了,但是在第一个脚本中,我得到了异常:没有方法的签名:java.lang.Class.login和电子邮件依赖()适用于参数类型:(java.lang.字符串)值:[abc]

会是什么问题呢?

共有1个答案

白君之
2023-03-14

代码没有问题。詹金斯的设置有问题。两个脚本有不同的设置,在第二个脚本中jenkins没有看到方法“loginMailDependency”

 类似资料: