ฉันมีการตั้งค่าต่อไปนี้:
(ถอดออก) Jenkinsfile:
@Library('my-custom-library') _
pipeline {
agent any
stages {
stage('Example') {
steps {
printHello name: 'Jenkins'
}
}
}
}
my-custom-library/resources/com/org/scripts/print-hello.sh:
#!/bin/bash
echo "Hello, $1"
my-custom-library/vars/printHello.groovy:
def call(Map parameters = [:]) {
def printHelloScript = libraryResource 'com/org/scripts/print-hello.sh'
def name = parameters.name
//the following line gives me headaches
sh(printHelloScript(name))
}
ฉันคาดหวัง Hello, Jenkins
แต่มันส่งข้อยกเว้นต่อไปนี้:
groovy.lang.MissingMethodException: ไม่มีลายเซ็นของวิธีการ: java.lang.String.call() ใช้ได้กับประเภทอาร์กิวเมนต์: (java.lang.String) ค่า: [Jenkins]
วิธีแก้ไขที่เป็นไปได้: wait(), any(), wait(long), split(java.lang.String), take(int), Each(groovy.lang.Closure)
เป็นไปได้ไหมที่จะทำสิ่งที่อธิบายไว้ข้างต้นโดยไม่ต้องผสมโค้ด Groovy และ Bash