Deploy-Helper เป็นเครื่องมือเล็ก ๆ สำหรับการปรับใช้สิ่งประดิษฐ์ที่กำหนดเป้าหมายไปที่นักพัฒนาซอฟต์แวร์
ฉันเขียน Deploy-Helper เพื่อช่วยฉันปรับใช้สิ่งประดิษฐ์ไปยังเครือข่ายทดสอบเมื่อฉันทำงานกับสิ่งต่าง ๆ ฉันอาจจะใช้ IDE ของฉันสำหรับสิ่งนั้น แต่นั่นก็ไม่สนุก!
ขั้นตอนโดยไม่ต้องปรับใช้:
ขั้นตอนด้วยการปรับใช้-ฮอลเปอร์:
ไฟล์กำหนดค่าเริ่มต้น deploy-helper.json ต้องอยู่ในไดเรกทอรีการทำงานของคุณ
ตัวอย่างการกำหนดค่า:
{
// Required
"destinations" : [
{
// Name of the destination
"name" : "service1" ,
// Normally you would set a real address or a ip here,
// but you could also use aliases from your ssh config (like I did here)
"address" : "test-network" ,
// The path for our destination (used for the ssh session)
"path" : "/home/user/services/service1/data/" ,
// SSH_COMMANDS (ssh first, then commands) or
// COMMANDS_SSH (commands first, then ssh)
"order" : "SSH_COMMANDS"
} ,
{
"name" : "service2" ,
"address" : "test-network" ,
"path" : "/home/user/services/service1/data/" ,
"order" : "SSH_COMMANDS"
}
] ,
// Required
"artifact" : {
// Directory that contains the artifact
"directory" : "./target" ,
// Name regex that matches the artifact
"name" : "my-software-[\d.A-Za-z-]+\.jar" ,
// Sorting operation for possible artifacts
// LAST_MODIFIED_ASC (oldest file first) or
// LAST_MODIFIED_DESC (newest file first)
"sort" : "LAST_MODIFIED_DESC"
} ,
// Optional
"commands" : [
// Can be either a string or an array of strings
"scp {ARTIFACT_PATH} {SSH_USER}@{DEST_ADDRESS}:{DEST_PATH}{ARTIFACT_NAME}"
] ,
// Optional
"ssh" : {
// If port is > 0, the ssh command will be USER@HOST:PORT
// If the port is <= 0, the ssh command will be USER@HOST
"port" : 0 ,
// How long to wait for the connection to establish
"sleep" : "2000" ,
// The ssh user
"user" : "user" ,
// Plaintext password auth requires 'sshpass'
// "password": "foobar",
"commands" : [
// Commands have to be a string
"rm my-software-*.jar"
]
}
}ตัวอย่างการกำหนดค่านี้ทำดังต่อไปนี้:
rm เพื่อลบสิ่งประดิษฐ์เก่าscp เพื่อคัดลอกสิ่งประดิษฐ์ใหม่ไปยังเซิร์ฟเวอร์ คุณควรเพิ่ม deploy-helper.json ในไฟล์. .gitignore ของคุณ
หมายเหตุ: สามารถมีสิ่งประดิษฐ์เดียวเท่านั้น
{DEST_ADDRESS} : ที่อยู่ปลายทาง
{DEST_NAME} : ชื่อปลายทาง
{DEST_PATH} : เส้นทางปลายทาง
{SSH_USER} : ผู้ใช้ SSH
{SSH_PORT} : พอร์ต ssh
{ARTIFACT_PATH} : เส้นทางสิ่งประดิษฐ์
{ARTIFACT_NAME} : ชื่อสิ่งประดิษฐ์
| ยาว | สั้น | คำอธิบาย |
|---|---|---|
| -การกำหนด | -c | แทนที่ตำแหน่งการกำหนดค่า |
| -verbose | -v | หากเปิดใช้งานเอาต์พุตกระบวนการจะถูกเปลี่ยนเส้นทางไปยัง stdout & stderr |
| --ปลายทาง | -d | แทนที่จุดหมายปลายทาง (รายการที่แยกจากกัน) |
การติดตั้ง Deploy-Helper นั้นง่ายพอ ๆ กับการดาวน์โหลดขวดจากรุ่นล่าสุด (ในทางทฤษฎี) อย่างไรก็ตามคุณควรเก็บขวดไว้ในที่ตั้งกลาง
นี่คือวิธีที่ฉัน 'ติดตั้ง' deploy-helper บนเครื่อง Linux ของฉันด้วย ZSH:
sudo mkdir /opt/deploy-helpersudo chown max:max /opt/deploy-helpermv ~/Downloads/deploy-helper-*.jar /opt/deploy-helperecho "alias deploy='java --enable-preview -jar /opt/deploy-helper/deploy-helper-VERSION.jar'" >> ~/.zshrc จากนั้นเพียงเปิดเทอร์มินัลของคุณอีกครั้ง (หรือ source ~/.zshrc ) แล้วคุณก็ทำเสร็จแล้ว!
คำสั่งพื้นฐาน:
java --enable-preview -jar deploy-helper-VERSION.jar OPTIONS
การผูกคำสั่งกับนามแฝง:
alias deploy='java --enable-preview -jar /opt/deploy-helper/deploy-helper-VERSION.jar'
เรียกใช้ Deploy-Helper ด้วยการกำหนดค่าอื่น:
deploy -c ~/my-deploy-config.json
กำลังเรียกใช้งาน Deploy-Helper ด้วยจุดหมายปลายทางที่ระบุ:
deploy -d service1,service4,service5
ข้อกำหนดเบื้องต้น:
ขั้นตอน:
git clone https://github.com/cerus/deploy-helper.gitcd deploy-helper ใหม่mvn clean packageโปรดปฏิบัติตามแนวทางการบริจาค