ฉันมีขั้นตอนต่อไปนี้ในไปป์ไลน์เจนกินส์ที่ประกาศของฉัน: ฉันสร้างสคริปต์ที่มาจากโฟลเดอร์ resources/
ของฉันโดยใช้ LibraryResource สคริปต์นี้มีข้อมูลรับรองสำหรับผู้ใช้ autobuild
ของฉันและสำหรับผู้ใช้ admintest
บางคน
stage('Build1') {
steps {
node{
def script = libraryResource 'tests/test.sh'
writeFile file: 'script.sh', text: script
sh 'chmod +x script.sh'
withCredentials([usernamePassword(credentialsId: xxx, usernameVariable: 'AUTOBUILD_USER', passwordVariable: 'AUTOBUILD_PASSWD')]){
sh './script.sh "
}
}
}
มันใช้งานได้ดี ฉันสามารถใช้ผู้ใช้ autobuild
ของฉันได้ ตอนนี้ฉันกำลังค้นหาวิธีที่ดีที่สุดในการรวมข้อมูลประจำตัวของผู้ใช้ admintest
ของฉันด้วย ฉันต้อง 'ซ้อน' กับส่วน withCredentials
ที่สองหรือไม่ หรือฉันจะเพิ่ม usernamePassword
'อาร์เรย์' อีกครั้งได้หรือไม่