jenkins - hudson.remoting.ProxyException:groovy.lang.MissingPropertyException:没有这样的属性:任何类:
问题描述
我有 jenkins 声明式管道,我也用声明式管道加载 sub_mudule 。
#!groovy
def jenkins_ci_examples = [String:Object]
def secrets_vault = "secrets_vault.groovy"
def vars=[String:Object];
pipeline {
agent any
stages{
stage("Begin"){
steps {
script {
stage("Checkout"){
deleteDir()
checkout scm
sh "git submodule foreach --recursive git pull origin master"
}
stage("import common_vars") {
vars = load "jenkins-ci-examples/vars/common_vars.groovy"
jenkins_ci_examples.common_vars = vars.UpdateVars();
}
stage("merge common and project_vars"){
vars = load "vars/project_vars.groovy"
jenkins_ci_examples.project_vars = vars.UpdateVars("ssh://git@git.com:8080/some/repo.git", "master")
jenkins_ci_examples.vars = jenkins_ci_examples.common_vars.GetVars()+ jenkins_ci_examples.project_vars.GetVars()
}
stage("import template ${secrets_vault}") {
println("${env.STAGE_NAME}")
currentBuild.displayName = "import template ${secrets_vault}"
currentBuild.description = "import template ${secrets_vault}"
sh "ls -las; cd jenkins-ci-examples; ls -las";
jenkins_ci_examples.sub_module = load "jenkins-ci-examples/${secrets_vault}"
}
stage("run template ${secrets_vault}") {
println("${env.STAGE_NAME}")
sh "ls -las; cd jenkins-ci-examples; ls -las";
jenkins_ci_examples.sub_module.ansible_secrets(jenkins_ci_examples.vars);
}
}
}
}
}
}
上下文加载 secrets_vault.groovy
def ansibledevops_secrets(HashMap <String,Object> vars)
{
def template1 ="spread_sshkeys"
pipeline {
agent any
stages {
stage('Dynamic Stages') {
steps {
script {
stage("import template ${template1}"){
println("${env.STAGE_NAME}")
}
stage("run template ${template1}"){
println("${env.STAGE_NAME}")
}
}
}
}
}
}
}
return this
尝试运行返回错误
hudson.remoting.ProxyException: groovy.lang.MissingPropertyException: No such property: any for class: Script3
但是如果使用脚本管道
node {
stage("Checkout") {
deleteDir()
checkout scm
sh "git submodule foreach --recursive git pull origin master"
print "Result " + vars;
}
}
没有错误。
帮助解决声明式管道变体的问题。
解决方案
推荐阅读
- mysql - 使用 Android Studio 从 MySql 中检索变量
- spring-boot - 与在 Kubernetes 集群上使用直接 RSocket 应用程序通信相比,Netifi 代理有哪些改进?
- node.js - 由于节点版本较新,无法更新 npm
- r - 使用R中的dplyr过滤所有包含高于/低于阈值的数字的列?
- javascript - amp-script 如何检测网络应用程序是否独立运行?
- javascript - 如何过滤 StartTime 和 EndTime 时间戳之间的对象数组并获取匹配记录
- java - 处理连接服务器-多客户端会出现错误:对等方重置连接:SocketException 中的套接字写入错误
- parsing - 单子的 Data.List 插入
- json - JSON弹性搜索解析
- python-3.x - tkinter - 更新刷新页面/文本以使用函数的新返回