git clone https://username:password@remote folderName;
或是git clone git@remot folderName;
我們選擇後面這種方式(因為http方式,密碼是明碼,而且密碼有特殊字元,也不行),詳細可以參考(多重 SSH Keys 與 Github 帳號)。cd ~/.ssh;
ssh-keygen -t rsa -b 4096;
2.2.將 .pub 檔案內容(public key) 新增到 Gitlab 之中(profile/keys),如下,#公司工作用的 GitHub 帳號Host gss
HostName 655git.655.com.tw(這裡可用ip or fqdn)
User rainmaker
IdentityFile ~/.ssh/id_rsa
2.4.將 Source 從 Gitlab 拉下來(@gss,就是對應到 .ssh/config 中的 Host ),git clone git@gss:BeaconSystem/iBeep-iOS.git iBeep-iOS;
3.透過 xbuild 來建置產生 ipk 檔案xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /p:BuildIpa=true
這時會發生 codesign FAILED 的問題,訊息如下,security -v unlock-keychain -p <<登入者的密碼>> ~/Library/Keychains/login.keychain;
mkdir ipa;
xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /p:BuildIpa=true /p:IpaPackageDir=./ipa/;
rm -rf ~/iBeep-iOS;
git clone git@gss:BeaconSystem/iBeep-iOS.git iBeep-iOS;
cd iBeep-iOS;
/Library/Frameworks/Mono.framework/Commands/nuget restore;
mkdir ipa;
security -v unlock-keychain -p <<登入者的密碼>> ~/Library/Keychains/login.keychain;
/Library/Frameworks/Mono.framework/Commands/xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /p:BuildIpa=true /p:IpaPackageDir=./ipa/;
其中 security unlock-keychain 需要密碼,所以可以設定在 Jenkins Job 「建置環境」中的 Inject passwords to the build as environment variables ,如下,rm -rf ~/iBeep-iOS;
git clone git@gss:BeaconSystem/iBeep-iOS.git iBeep-iOS;
cd iBeep-iOS;
/Library/Frameworks/Mono.framework/Commands/nuget restore;
mkdir ipa;
security -v unlock-keychain -p ${keychainPW} ~/Library/Keychains/login.keychain;
/Library/Frameworks/Mono.framework/Commands/xbuild /p:Configuration=Release /p:Platform=iPhone /p:ArchiveOnBuild=true /p:BuildIpa=true /p:IpaPackageDir=./ipa/;
另外,如果透過 Jenkins 連進去有 Algorithm negotiation fail 的錯誤,可依以這篇(JSch连接SSH问题Exception:Algorithm negotiation fail)去設定哦!