提问人:user20119155 提问时间:11/7/2023 更新时间:11/7/2023 访问量:17
Jenkinsfile 用户名和密码凭据无法传递给 Packer
Jenkinsfile Username and Password credentials cannot pass over to Packer
问:
我有 Jenkins 版本 2.401.3 打包器 1.9.4
下面是我的 Jenkinsfile
pipeline {
agent any
environment {
AWS_CRED = credentials('AWS_SECRET')
}
stages {
stage('Packer - Build Ubuntu Image on AWS') {
steps {
sh '''
#!/bin/bash
packer validate ubuntu-aws.json
packer build -var access_key=$AWS_CRED_USR -var secret_key=$AWS_CRED_PSW ubuntu-aws.json
'''
}
}
}
}
我很难传递凭据。 错误:NoCredentialProviders:链中没有有效的提供程序。荒废的。 有关详细的消息收发,请参阅 aws。Config.CredentialsChainVerboseErrors
错误显示凭据不匹配,但我认为这不是由 Jenkins 凭据引起的,因为我可以回显用户名和密码。
{
"variables": {
"aws_access_key": "",
"aws_secret_key": "",
"region": "ap-southeast-1",
"instance_type": "t2.micro"
},
"builders": [
{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key` }}",
"secret_key": "{{user `aws_secret_key` }}",
"region": "{{user `region` }}",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*",
"root-device-type": "ebs"
},
"owners": ["099720109477"],
"most_recent": true
},
"instance_type": "{{user `instance_type`}}",
"ssh_username": "{{user `ssh_username`}}",
"ami_name": "packer-base-{{timestamp}}",
"subnet_id": "subnet-0eb53daf294979531",
"associate_public_ip_address": true,
"user_data_file":"./defaults.cfg"
}
],
我的打包器代码片段。
从 Jenkinsfile 凭证传递的正确方法是什么file 凭证> Packer > AWSCLI 验证
答: 暂无答案
评论