Jenkins使用腳本執(zhí)行pod命令結(jié)果報(bào)錯(cuò)pod: command not found 、jenkins 腳本執(zhí)行pod install 和 pod update --verbose --no...

前言

因?yàn)槭褂肑enkins自動(dòng)化打包,后來(lái)需要每次打包的時(shí)候執(zhí)行pod update --verbose --no-repo-upadte命令,但是會(huì)報(bào)錯(cuò)誤,經(jīng)過(guò)努力,解決了這個(gè)問(wèn)題。
首先你得安裝并且搭建了Jenkins打包系統(tǒng),并且集成的Jenkins是用cocoaPods管理三方庫(kù)的,詳細(xì)教程:Jenkins安裝、配置、構(gòu)建、腳本、配置郵箱、上傳fir該教程

按照Jenkins安裝、配置、構(gòu)建、腳本、配置郵箱、上傳fir教程搭建Jenkins完畢之后,在腳本里面加上下面的命令,然后構(gòu)建這個(gè)項(xiàng)目

cd /Users/用戶/.jenkins/workspace/打包的項(xiàng)目/
pod install
pod update --verbose --no-repo-update

出現(xiàn)的錯(cuò)誤以及解決辦法

E1

Jenkins構(gòu)建之后的結(jié)果(圖1),很明顯的錯(cuò)誤line 22: pod: command not found這個(gè)是指,腳本第22行執(zhí)行的命令找不到。

圖1

S1

出現(xiàn)這個(gè)問(wèn)題可能是因?yàn)槟銢](méi)有設(shè)置pod的運(yùn)行路徑,解決方法如下
第一步:打開(kāi)Jenkins,然后在Jenkins左側(cè)的菜單中找到 系統(tǒng)管理--->系統(tǒng)設(shè)置--->全局屬性,然后找到Environment variables(中文:環(huán)境變量)并且勾選。
第二步:打開(kāi)你的終端,在終端中輸入echo $PATH,終端會(huì)打印出一串字符串,幾個(gè)路徑,復(fù)制該路徑,返回到Jenkins中
第三步:會(huì)讓填寫(xiě)一個(gè)鍵值對(duì),鍵默認(rèn)填寫(xiě)PATH,值填寫(xiě)你從終端復(fù)制的那個(gè)字符串,點(diǎn)擊保存,完成,構(gòu)建該項(xiàng)目。

E2

解決E1問(wèn)題后,出現(xiàn)了E2問(wèn)題,因該錯(cuò)誤結(jié)果過(guò)長(zhǎng),就不再截圖,并且只保留了錯(cuò)誤前面的一部分,也就是最重要的一部分。

<pre class="console-output" style="box-sizing: border-box; white-space: pre-wrap; word-wrap: break-word; margin: 0px; color: rgb(51, 51, 51); font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">   ?[33mWARNING: CocoaPods requires your terminal to be using UTF-8 encoding.
    Consider adding the following to ~/.profile:

    export LANG=en_US.UTF-8
    ?[0m
Analyzing dependencies

――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Command

/```
/Users/apple/.rvm/rubies/ruby-2.4.1/bin/pod install
/```

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?

### Stack

/```
   CocoaPods : 1.5.3
        Ruby : ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin17]
    RubyGems : 2.6.14
        Host : Mac OS X 10.13.3 (17D47)
       Xcode : 9.4.1 (9F2000)
         Git : git version 2.15.2 (Apple Git-101.1)
Ruby lib dir : /Users/apple/.rvm/rubies/ruby-2.4.1/lib
Repositories : ***songshuaijie-lfanalyticpodspec - [http://git.***.net/songshuaijie/LFAnalyticPodspec.git](http://git.***.net/songshuaijie/LFAnalyticPodspec.git) @ a15947a36195d7352f98d620bfde58d57ae6c0e1
               master - [https://github.com/CocoaPods/Specs.git](https://github.com/CocoaPods/Specs.git) @ b2d3d6a0fee0b212dd40b2728643c05445ca8d69
/```

### Plugins

/```
cocoapods-deintegrate : 1.0.2
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.0.0</pre>

S2

錯(cuò)誤中已經(jīng)提示了export LANG=en_US.UTF-8,所以在腳本中加入他們,加在你cd的那個(gè)目錄后面就可以了。然后就可以再次構(gòu)建該項(xiàng)目。

cd /Users/用戶/.jenkins/workspace/打包的項(xiàng)目/
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

pod install
pod update --verbose --no-repo-update

目前我這里就沒(méi)有問(wèn)題了,可能會(huì)有其它問(wèn)題,我遇到后會(huì)更新的。


轉(zhuǎn)載請(qǐng)注名出處


最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容