You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins流水线报错:未找到DSL方法'AWS',如何解决?

解决Jenkins流水线提示"No such DSL method 'AWS'"的问题

问题原因

你在流水线里直接调用AWS()作为DSL步骤,但Jenkins既没有内置这个DSL方法,它也不是AWS插件提供的标准步骤——你混淆了Jenkins DSL步骤和AWS CLI命令的用法。

修复方案

把流水线中的AWS("--region=eu-north-1 eks list-clusters")替换为用sh步骤执行AWS CLI命令的写法:

修改后的完整流水线代码:

stage('List staging eks cluster') {
    agent {
        label 'jenkins-jnlp'
    }
    steps {
        withAWS(roleAccount:'xxxxxxxxxx', role:'cross-account-role') {
            sh 'aws --region=eu-north-1 eks list-clusters'
        }
    }
}

额外注意事项

  • 确保你的Jenkins inbound-agent容器内已安装AWS CLI,如果未安装,可在流水线中添加前置安装步骤(例如sh 'apt-get update && apt-get install -y awscli'或通过pip安装)。
  • 确认withAWS插件已正确配置角色权限,能让容器内的AWS CLI获取临时凭证执行命令。

内容的提问来源于stack exchange,提问作者mair

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 06:07:46