Jenkins java.lang.NullPointerException:无法调用方法
有下一个领域,我试图在我的工作结果发送松弛Jenkins java.lang.NullPointerException:无法调用方法,jenkins,jenkins-pipeline,jenkins-groovy,Jenkins,Jenkins Pipeline,Jenkins Groovy,有下一个领域,我试图在我的工作结果发送松弛 } finally { sh(script: 'ls -lah') slack.jobResultNotification(currentBuild.result, '#some_channel',null,null,null,'https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXX') } } 但每次我 j
} finally {
sh(script: 'ls -lah')
slack.jobResultNotification(currentBuild.result, '#some_channel',null,null,null,'https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXX')
}
}
但每次我
java.lang.NullPointerException: Cannot invoke method getSecret() on null object
用于松弛通知的函数(我只添加了代码的重要部分)
为了信誉
def getCredentialsById(String credsId, String credsType = 'any') {
def credClasses = [ // ordered by class name
sshKey : com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.class,
cert : com.cloudbees.plugins.credentials.common.CertificateCredentials.class,
password : com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class,
any : com.cloudbees.plugins.credentials.impl.BaseStandardCredentials.class,
dockerCert: org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials.class,
file : org.jenkinsci.plugins.plaincredentials.FileCredentials.class,
string : org.jenkinsci.plugins.plaincredentials.StringCredentials.class,
]
return com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
credClasses[credsType],
jenkins.model.Jenkins.instance
).findAll { cred -> cred.id == credsId }[0]
}
您是否有ID为
的凭证https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXX“
当查看您的.jenkins.url/凭证时?是的!我试图使用slack integration id。我得到了相同的id。您有id为的凭据吗https://hooks.slack.com/services/XXXXXX/XXXXXX/XXXXXXX“
当查看您的.jenkins.url/凭证时?是的!我试着使用slack集成id。我得到了同样的结果。
def getCredentialsById(String credsId, String credsType = 'any') {
def credClasses = [ // ordered by class name
sshKey : com.cloudbees.jenkins.plugins.sshcredentials.impl.BasicSSHUserPrivateKey.class,
cert : com.cloudbees.plugins.credentials.common.CertificateCredentials.class,
password : com.cloudbees.plugins.credentials.common.StandardUsernamePasswordCredentials.class,
any : com.cloudbees.plugins.credentials.impl.BaseStandardCredentials.class,
dockerCert: org.jenkinsci.plugins.docker.commons.credentials.DockerServerCredentials.class,
file : org.jenkinsci.plugins.plaincredentials.FileCredentials.class,
string : org.jenkinsci.plugins.plaincredentials.StringCredentials.class,
]
return com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
credClasses[credsType],
jenkins.model.Jenkins.instance
).findAll { cred -> cred.id == credsId }[0]
}