我希望在HashiCorp Vault中存储ssh密钥,然后在我的Jenkins文件中,我想获取我的密钥并使用它来检查并提交到存储库,是否可能或应该采用传统方式,在Jenkins中定义凭据然后使用它。这个问题的目的是因为我想在Vault中保留所有秘密信息
答案 0 :(得分:3)
我相信您正在寻找Hashicorp Vault Plugin - 这可以让您在Jenkinsfile as shown here中访问机密:
const info = (msg) => {
/* istanbul ignore next */
console.info(chalk.hex('#00f2ff')(msg));
};
const failure = (msg) => {
/* istanbul ignore next */
console.error(chalk.hex('#F9060B')(msg));
};
/**
* create configuration with configuration file's values if present
* make related prompts to be skipped
*
* @resolves configuration object
*/
const init = () => fse.readJson(cst.configFile)
.then((config) => {...})
.catch((error) => {
if (error.errno === -2) {
info(cst.messages.noConfig);
} else {
failure(error);
}
return {}; // if an error occurs, loads nothing.
});
答案 1 :(得分:0)
您可以使用相同的Vault jenkins插件来实现。
withVault(configuration: [timeout: 60, vaultCredentialId: '<ur vault credential>', vaultUrl: '<ur vault URL>'], vaultSecrets: [[path: 'secret/<ur secret ssh path>', secretValues: [[vaultKey: '<ur key of ssh>']]]]) {
//use as env.<<ur key of ssh>>
}