简体   繁体   English

如何在 Jenkins 中使用 withCredentials for Perforce?

[英]How to use withCredentials for Perforce in Jenkins?

I am attempting to retrieve the credentials for Perforce in my Jenkinsfile .我正在尝试在我的Jenkinsfile中检索 Perforce 的凭据。 The p4 credentials are saved using the standard Jenkins credentials store. p4 凭据使用标准 Jenkins 凭据存储进行保存。 I need the credentials to be in scope so that I can call a utility that will invoke p4 operations from a utility.我需要凭据在范围内,以便我可以调用一个实用程序,该实用程序将从实用程序调用p4操作。 The utility expects the P4PORT environment variable to be set.该实用程序需要设置P4PORT环境变量。

I am aware of withCredentials , however, I am not sure how to leverage this to retrieve the P4Port property saved on the credential.我知道withCredentials ,但是,我不确定如何利用它来检索保存在凭据上的P4Port属性。

The closest credentials binding I've found is usernamePassword() , however that doesn't seem to be able to give me access to the P4Port property.我找到的最接近的凭据绑定是usernamePassword() ,但这似乎无法让我访问P4Port属性。

The error I am experiencing is:我遇到的错误是:

Credentials 'my-credentials-id' is of type 'Perforce Password Credential'...

Is there a binding that is intended to be used with 'Perforce Password Credential' ?是否存在旨在与'Perforce Password Credential'一起使用的绑定?

The binding to a variable is handled by https://plugins.jenkins.io/credentials-binding/与变量的绑定由https://plugins.jenkins.io/credentials-binding/处理

It only supports specific types of credentials, see https://javadoc.jenkins.io/plugin/credentials/com/cloudbees/plugins/credentials/common/package-summary.html它仅支持特定类型的凭据,请参阅https://javadoc.jenkins.io/plugin/credentials/com/cloudbees/plugins/credentials/common/package-summary.html

So the credentials plugin would have to have a credential Interface that allows access to additional information, specifically your P4PORT.因此,凭证插件必须有一个凭证接口,允许访问其他信息,特别是您的 P4PORT。 Then the p4 plugin could implement it.然后 p4 插件可以实现它。

The p4 plugin supports the username/password (StandardUsernamePasswordCredentials) with the perforce password credential. p4 插件支持带有 perforce 密码凭据的用户名/密码 (StandardUsernamePasswordCredentials)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM