Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
751 views
in Technique[技术] by (71.8m points)

jenkins - Issue executin groovy command usingJenkins job dsl creating another job

I was creating JOBdsl in jenkins

here is the piece of code

      job(deployJobPath) {
 
      systemGroovyCommand(readFileFromWorkspace('eg.groovy'))
 }

eg.groovy is as below

import jenkins.model.*
import groovy.json.JsonSlurper
import hudson.model.*
def data
def str

node("slave_agent_1"){

    checkout scm
  
   stage('Invoke__job') {

        build job: 'manager/'+str,
        parameters: [
          [$class: 'StringParameterValue', name: 'nodeName', value: "slave_agent_1"],
          [$class: 'StringParameterValue', name: 'devDockerRepo', value: "repo.io"],
          [$class: 'StringParameterValue', name: 'verion', value: data],
          [$class: 'StringParameterValue', name: 'dockerHubCredId', value: "test"]
       ]

    }


  
  stage('Apply Kubernetes files') {
    withKubeConfig([credentialsId: 'jenkins-devdep2', serverUrl: 'https://x.x.:123']) 
   {
      sh 'kubectl set image ----'
  
  }
}



Note :: data is variable

I am getting error as 22:58:12 groovy.lang.MissingMethodException: No signature of method: Script1.node() is applicable for argument types: (java.lang.String, Script1$_run_closure1) values: [slave_agent_1, Script1$_run_closure1@63e8fe8e] 22:58:12 Possible solutions: notify(), wait(), run(), run(), any(), grep()

New to jenkins,please pour suggestion

Tried with groovyCommand(readFileFromWorkspace('eg.groovy')) stil it fails


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...