先上腳本代碼:
首先需要安裝一下 expect奏夫,關(guān)于expect的使用方式參考文末的鏈接
#!/usr/bin/expect
spawn ssh userxxx@192.168.86.200
expect {
"*Password*" {send "123\r"; exp_continue}
}
// 非本機(jī)需要解鎖keychain嚼吞,要不然無法執(zhí)行xcodeBuild
send "security unlock-keychain\r"
expect {
"*password*" {send "123\r"; exp_continue}
}
// 切換到項(xiàng)目目錄儒拂,切換到需要打包的分支,拉取最新代碼
send "cd /Users/dongyuan/xxxxxx\r"
send "git branch\r"
send "git checkout develop\r"
send "git pull\r"
// git賬號(hào)皇筛、密碼
expect {
"*Username*" {send "xxxx@qq.com\r"; exp_continue}
"*Password*" {send "xxxx\r"; exp_continue}
}
// 切換到腳本文件夾下琉历,執(zhí)行腳本
send "cd buildTool\r"
send "python /Users/xxx/xxx/buildTool/iosapp-package.py\r"
interact