Jenkins

坑1:sh: adb: command not found

背景:在任务中使用了adb命令

adb 使用时要在服务器上配Android-home的环境变量的

配置完成之后发现在服务器上 adb OK,但是在jenkins 执行job时不OK

参考一下两篇文档

https://stackoverflow.com/questions/29216244/jenkins-build-failed-due-to-missing-android-sdk

http://www.linuxdiyf.com/linux/28771.html

1. 在jenkins 设置里配置Android-home,然而并没有用

2. 在Execute shell 里将#!/bin/bash 改成 #!/bin/bash -ilex

jenkins没有加载/etc/profile导致,需要在jenkins调用shell脚本的最前面加一行脚本,#!/bin/bash -ilex,可以通过-i参数和-l参数让bash为login shell and interactive shell,就可以读取/etc/profile和~/.bash_profile等文件

3. 实际挨个试了下#!/bin/bash -ilex中的各个参数 发现有用的是-l

对于e参数表示一旦出错,就退出当前的shell,x参数表示可以显示所执行的每一条命令。

'''

-l        Make bash act as if it had been invoked as a login shell (see

INVOCATION below).

When  bash is invoked as an interactive login shell, or as a non-inter-

active shell with the --login option, it first reads and executes  com-

mands  from  the file /etc/profile, if that file exists.  After reading

that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile,

in  that order, and reads and executes commands from the first one that

exists and is readable.  The --noprofile option may be  used  when  the

shell is started to inhibit this behavior.

'''

综上,就是加载了/etc/profile或者其他几个配置环境变量的文件

所以直接改成在 shell 脚本里增加source /etc/profile就好啦~

坑2 Jenkins + python 的任务,console output 没有及时输出日志

期初是以为是 #!/bin/bash -ilex 中四个参数导致console output 没有输出,后来突然意识到是python的print应该有buffer的问题

https://stackoverflow.com/questions/22826006/how-to-get-python-print-result-in-jenkins-console-output

https://stackoverflow.com/questions/11631951/jenkins-console-output-not-in-realtime

有两种解释

1.jenkins 要输入换行符才能展示数据

Any output to stdout from a process spawned by Jenkins should be captured by Console Output. One caveat is that it won't be displayed until a newline character is printed, so make sure your lines are terminated.

2.print有buffer

  • ruby or python or any sensible scripting language will buffer the output; this is in order to minimize the IO; writing to disk is slow, writing to a console is slow...
  • usually the data gets flush()'ed automatically after you have enough data in the buffer with special handling for newlines. e.g. writing a string without newline then sleep() would not write anything until after the sleep() is complete (I'm only using sleep as an example, feel free to substitute with any other expensive system call).

解决方法看到两个

1.print 信息后加sys.stdout.flush()

2. 执行python时增加 -u 参数,即 python -u XXX.py

  • for python, you can use python -u or the environment variable PYTHONUNBUFFERED to make stdin/stdout/stout not buffered, but there are other solutions that do not change stdin or stderr

    export PYTHONUNBUFFERED=1

[Jenkins] 配置任务中的坑s的更多相关文章

  1. jenkins配置过程中踩过的一些坑

    1,编译通过之后,想要将编译好的war包放到远程服务器上,并解压 unzipBus.sh的脚本如下: #!/bin/bash jar -xvf bus.war 编译后报错:jar:Command no ...

  2. 菜鸟帮你跳过openstack配置过程中的坑

    一:前言 对于一个以前做java全栈工程师而言,而且没学过Linux,很少用虚拟机(还是在大学的时候简单的用过),去配置openstack我想我入的坑肯定比有基础的一定要多,躺在每个坑中徘徊思索的时间 ...

  3. 菜鸟帮你跳过openstack配置过程中的坑[文末新添加福利]

    一:前言 对于一个以前做java全栈工程师而言,而且没学过Linux,很少用虚拟机(还是在大学的时候简单的用过),去配置openstack我想我入的坑肯定比有基础的一定要多,躺在每个坑中徘徊思索的时间 ...

  4. Filezilla配置FTP中的坑以及出坑办法

    做本科生助教,老板让配置一个FTP传资料交作业,找了一台Windows服务器捣鼓,开始按网上教程自己配置特别麻烦,何西西说用Filezilla比较方便,就去Filezilla官网下载了Filezill ...

  5. phpfpm配置 php中的坑

    ###### 记一些坑```//phpfpm配置pm.max_children = 最大并发数详细的答案:pm.max_children 表示 php-fpm 能启动的子进程的最大数量.因为 php- ...

  6. Redis配置过程中的问题

    记录一下配置过程中的坑~~ 当Redis在服务器上安装完成后,get.set没有问题了,接下来在程序中使用看看... 首先 在配置文件redis.conf中,默认的bind 接口是127.0.0.1, ...

  7. jenkins自动化构建iOS应用配置过程中遇到的问题

    最近配置jenkins来自动构建iOS应用,期间遇上不少问题.在这里分享给大家,也给自己留个底,方便下次解决问题. 首先说明下基本情况,我们因为部署jenkins的机器不是Mac,所以不能安装Xcod ...

  8. 外部Jenkins调用容器中Slave配置实践

    1.Jenkins配置 实现动态生成的Slave节点并调用,解决构建项目出现slave节点任务堵塞或者是slave宕机问题.容器平台采用openshift. 参考配置文档:https://blog.c ...

  9. 记pytorch版faster rcnn配置运行中的一些坑

    记pytorch版faster rcnn配置运行中的一些坑 项目地址 https://github.com/jwyang/faster-rcnn.pytorch 一般安装配置参考README.md文件 ...

随机推荐

  1. 通过ICE轻松部署WES7镜像

    作者:雷志刚 转自:http://lzg-ad.blog.sohu.com/156323256.html 注:该文转自Happymy,感谢他的技术提供和分享. 本文适合的软件版本:CTP,RC 如果大 ...

  2. linux命令: 两个查找工具 locate,find

    linux 中有很多查找工具,今天主要讲解locate,find两个工具. 1.locate (1)查询系统上预建的文件索引数据库 /var/lib/mlocate/mlocate.db 注意:如果这 ...

  3. mysql使用存储过程和event定期删除

    -- 创建存储过程DELIMITER //CREATE PROCEDURE del_data()BEGIN DELETE FROM t_route_status WHERE route_date &l ...

  4. keepalived实现高可用

    准备: 1.A-centos(192.168.6.177)  端口为9898的服务 2.B-ubuntu(192.168.6.182)  端口为9898的服务 3.keepalived安装包https ...

  5. bootstrap 下拉菜单自动向上向下弹起

    .别人的解决方案 2.别人的解决方案 3.我哒 div class="btn-group" style="margin-top:500px;" > < ...

  6. 关于MySQL慢日志,你想知道的都在这

    关于MySQL慢日志,你想知道的都在这 https://mp.weixin.qq.com/s/Ifbq0Dk13SO3WVghqWVUbA 作者介绍邹鹏,现任职于腾讯云数据库团队,负责腾讯云数据库My ...

  7. 【UML】NO.50.EBook.5.UML.1.010-【UML 大战需求分析】- 考勤系统

    1.0.0 Summary Tittle:[UML]NO.50.EBook.1.UML.1.010-[UML 大战需求分析]- 考勤系统 Style:DesignPattern Series:Desi ...

  8. [LeetCode] 系统刷题2_排列组合

    要用到backtracking,是否要跟backtracking放到一起总结? 适用范围: 几乎所有搜索问题 什么时候输出 哪些情况需要跳过 相关题目: [LeetCode] 78. Subsets ...

  9. 关于mongodb基础的命令

    banji----数据库 class---集合 1.查看所在的数据库 db 2.查看所有的数据库 show dbs 3.创建数据库 use banji #查看所有的数据库show dbs,创建的数据库 ...

  10. 3.Python3变量与基本数据类型

    3.1保留字和标识符 3.1.1保留字 保留字是Python语言中已经被赋予特定意义的一些单词,开发程序时不可以把保留字作为变量.函数.类.模块和其他对象的名称来使用.保留字如下: 3.1.2标识符 ...