ฉันมี jenkinsfile ที่ใช้งานได้และสามารถปรับใช้โครงสร้างพื้นฐานบางอย่างโดยอัตโนมัติด้วย Terraform น่าเสียดายหลังจากเพิ่มโมดูล Terraform ด้วยซอร์ส git มันหยุดทำงานโดยมีข้อผิดพลาดต่อไปนี้:
+ terraform init -input=false -upgrade
Upgrading modules...
- module.logstash
Updating source "git::https://bitbucket.org/*****"
Error downloading modules: Error loading modules: error downloading 'https://bitbucket.org/*****': /usr/bin/git exited with 128: Cloning into '.terraform/modules/34024e811e7ce0e58ceae615c545a1f8'...
fatal: could not read Username for 'https://bitbucket.org': No such device or address
script returned exit code 1
URL ข้างต้นถูกทำให้สับสนหลังจากข้อเท็จจริงแล้ว ด้านล่างนี้คือไวยากรณ์ของโมดูลแบบตัดทอน:
module "logstash" {
source = "git::https://bitbucket.org/******"
...
}
ด้านล่างเป็นไฟล์ Jenkins:
pipeline {
agent {
label 'linux'
}
triggers {
pollSCM('*/5 * * * *')
}
stages {
stage ('init') {
steps {
sh 'terraform init -input=false -upgrade'
}
}
stage('validate') {
steps {
sh 'terraform validate -var-file="production.tfvars"'
}
}
stage('deploy') {
when {
branch 'master'
}
steps {
sh 'terraform apply -auto-approve -input=false -var-file=production.tfvars'
}
}
}
}
ฉันเชื่อว่านี่เป็นปัญหากับ Terraform ภายในโดยใช้ git เพื่อชำระเงินโมดูล แต่ Jenkins ไม่ได้กำหนดค่าไคลเอนต์ git ภายในงานไปป์ไลน์เอง โดยเฉพาะอย่างยิ่งฉันสามารถส่งข้อมูลรับรองที่ใช้โดยงานไปป์ไลน์แบบหลายสาขาไปยังงานเองและกำหนดค่าคอมไพล์ได้ แต่ฉันไม่รู้ว่าจะทำอย่างไร ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชม
withCredentials
ใด ๆ ในรหัสไปป์ไลน์ของคุณ - person Matt Schuchard   schedule 11.10.2018