Jenkins使用脚本执行pod命令结果报错pod: command not found 、jenkins 脚本执行pod install 和 pod update --verbose --no...

前言

因为使用Jenkins自动化打包,后来需要每次打包的时候执行pod update --verbose --no-repo-upadte命令,但是会报错误,经过努力,解决了这个问题。
首先你得安装并且搭建了Jenkins打包系统,并且集成的Jenkins是用cocoaPods管理三方库的,详细教程:Jenkins安装、配置、构建、脚本、配置邮箱、上传fir该教程

按照Jenkins安装、配置、构建、脚本、配置邮箱、上传fir教程搭建Jenkins完毕之后,在脚本里面加上下面的命令,然后构建这个项目

cd /Users/用户/.jenkins/workspace/打包的项目/
pod install
pod update --verbose --no-repo-update

出现的错误以及解决办法

E1

Jenkins构建之后的结果(图1),很明显的错误line 22: pod: command not found这个是指,脚本第22行执行的命令找不到。

《Jenkins使用脚本执行pod命令结果报错pod: command not found 、jenkins 脚本执行pod install 和 pod update --verbose --no...》 图1

S1

出现这个问题可能是因为你没有设置pod的运行路径,解决方法如下
第一步:打开Jenkins,然后在Jenkins左侧的菜单中找到 系统管理—>系统设置—>全局属性,然后找到Environment variables(中文:环境变量)并且勾选。
第二步:打开你的终端,在终端中输入echo $PATH,终端会打印出一串字符串,几个路径,复制该路径,返回到Jenkins中
第三步:会让填写一个键值对,键默认填写PATH,值填写你从终端复制的那个字符串,点击保存,完成,构建该项目。

E2

解决E1问题后,出现了E2问题,因该错误结果过长,就不再截图,并且只保留了错误前面的一部分,也就是最重要的一部分。

<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

错误中已经提示了export LANG=en_US.UTF-8,所以在脚本中加入他们,加在你cd的那个目录后面就可以了。然后就可以再次构建该项目。

cd /Users/用户/.jenkins/workspace/打包的项目/
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

目前我这里就没有问题了,可能会有其它问题,我遇到后会更新的。

转载请注名出处

    原文作者:差不多先生__
    原文地址: https://www.jianshu.com/p/3ef37b9538bf
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞