我有一个 groovy 脚本,它将使用所需的数据配置 AWS ec2 插件。我能够配置所有其他输入。我需要在同一区域提供私钥,有什么方法可以在 grrovy 脚本中生成和配置此密钥。遵循以下文档和模板。 https://gist.github.com/vrivellino/97954495938e38421ba4504049fd44ea https://github.com/jenkinsci/ec2-plugin/blob/master/src/main/java/hudson/plugins/ec2/SlaveTemplate.java
问问题
547 次
2 回答
1
这将帮助您获取 Jenkins 私钥:
EC2Cloud cloud = Jenkins.instance.clouds.find { it instanceof EC2Cloud }
KeyPair key_pair= cloud.getKeyPair()
private_key_text = key_pair.keyMaterial
def secret_key = hudson.util.Secret.decrypt(cloud.getSecretKey()).toString()
于 2018-03-28T23:41:55.560 回答
0
我不确定这是否是您问题的正确答案,但是当我想破译 EC2 Jenkins 插件的私钥时,这就是 Google 引导我的地方。这对我有用 Jenkins 2.190.2。
import hudson.plugins.ec2.AmazonEC2Cloud
def cloud = Jenkins.instance.clouds.find { it instanceof AmazonEC2Cloud }
println cloud.getKeyPair().keyMaterial
于 2020-07-23T17:38:23.320 回答