Chinaunix

标题: hudson执行不了gmake [打印本页]

作者: 只为踏雪寻梅    时间: 2011-05-24 09:01
标题: hudson执行不了gmake
Dear ALL
     我的hudson一个任务想执行gmake命令去编译后台的模块。hudson里面是这么配置的Execute shell->Command :/var/lib/hudson/build.sh -label $JOB_NAME-$BUILD_NUMBER
build.sh脚本如下:
#!/bin/bash

#OB_REL=/root/result

cd $WORKSPACE
echo "WORKSPACE:="$WORKSPACE;
gmake -f Makefile
cd $OB_REL
cd $OB_REL/lib
ls -tlr *.sl
dltest *.sl
能加载到WORKSPACE目录下,但是执行gmake不正确,手工执行没问题。
还请高人指点!
作者: xiaopan3322    时间: 2011-05-24 10:00
好亲切啊,第一次在shell版看到有人问Hudson的……
作者: xiaopan3322    时间: 2011-05-24 10:07
设置步骤没问题,我有几个疑问:
1,Hudson搭在哪里?
2,命令行中有 -label选项,但是你的脚本中呢?没用到啊?
3,$WORKSPACE是环境变量,但是$OB_REL呢,是什么变量?
4,你的命令是在哪里执行的?master上,还是slave上?什么OS环境?
作者: 只为踏雪寻梅    时间: 2011-05-24 10:15
回复 3# xiaopan3322


    1.HUDSON大家在Linux环境下面
    2.应该是我不太理解-label选项的意义 还望讲解下
    3.$WORKSPACE是HUDSON的任务工作区,没有加载到环境变量中,这个能shell脚本中应该能直接调用 $OB_REL是环境变量
    4.命令应该是在master上面执行
       [root@rhel142 hudson]# uname -a
Linux rhel142 2.6.18-128.2.1.el5 #1 SMP Wed Jul 8 11:54:47 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
作者: xiaopan3322    时间: 2011-05-24 10:21
回复 4# 只为踏雪寻梅


    -label就是你自己脚本里写的入参……不过我想这里应该没关系,因为你没有错误判断
    WORKSPACE是Hudson本身的环境变量,可以直接使用的
   
WORKSPACE
    The absolute path of the workspace.

   
    把你的Hudson的Console Output贴出来!!!
作者: 只为踏雪寻梅    时间: 2011-05-24 10:40
回复 5# xiaopan3322


    Started by user anonymous
[workspace] $ /bin/sh -xe /tmp/hudson8655029990995273156.sh
+ /var/lib/hudson/build.sh example-31
WORKSPACE:=/var/lib/hudson/jobs/example/workspace
Makefile:8: /etc/Tmp.mk: No such file or directory
Makefile:59: /etc/CALLmake: No such file or directory
gmake: *** No rule to make target `/etc/CALLmake'.  Stop.
ls: *.sl: No such file or directory
[dltest] ERROR dlopen: *.sl: cannot open shared object file: No such file or directory

Tmp.mk和CALLmake在$OB_REL的etc目录下面都有  而且本身Makefile定义的路径也定义在$(OB_REL)/etc/
作者: xiaopan3322    时间: 2011-05-24 10:54
回复 6# 只为踏雪寻梅


Makefile:8: /etc/Tmp.mk: No such file or directory
Makefile:59: /etc/CALLmake: No such file or directory
gmake: *** No rule to make target `/etc/CALLmake'.  Stop.
ls: *.sl: No such file or directory
[dltest] ERROR dlopen: *.sl: cannot open shared object file: No such file or directory

Tmp.mk和CALLmake在$OB_REL的etc目录下面都有  而且本身Makefile定义的路径也定义在$(OB_REL)/etc/


打印一下${OB_REL}这个变量
作者: 只为踏雪寻梅    时间: 2011-05-24 10:56
回复 7# xiaopan3322


    [root@rhel142 workspace]#
[root@rhel142 workspace]# echo $OB_REL
/root/result
作者: xiaopan3322    时间: 2011-05-24 11:07
本帖最后由 xiaopan3322 于 2011-05-24 11:09 编辑

回复 8# 只为踏雪寻梅


    好,那你再回过头去看看你的log:
Makefile:8: /etc/Tmp.mk: No such file or directory
Makefile:59: /etc/CALLmake: No such file or directory
gmake: *** No rule to make target `/etc/CALLmake'.  Stop.
ls: *.sl: No such file or directory
[dltest] ERROR dlopen: *.sl: cannot open shared object file: No such file or directory

Tmp.mk和CALLmake在$OB_REL的etc目录下面都有  而且本身Makefile定义的路径也定义在$(OB_REL)/etc/

而你的$OB_REL路径却是:
[root@rhel142 workspace]# echo $OB_REL
/root/result

    明白了吗???
作者: xiaopan3322    时间: 2011-05-24 11:14
本帖最后由 xiaopan3322 于 2011-05-24 11:27 编辑

再和你说的简单点吧:
就是把你的脚本中的这句话打开,不要注释掉:
#OB_REL=/root/result
->
OB_REL=/root/result

这样做的原因是:
Hudson并不认你的系统上(包括master和slave)的环境变量,它只认自己内部的环境变量……
如果你想用也可以,应该有三种方法:
1. 直接再定义一遍,也就是你这里的情况
2. source .bashrc或者其他的写有环境变量的脚本
3. 配置Hudson的node中的环境变量:
Hudson -> Nodes -> <node name> -> Configure -> Node Properties -> Environment variables中设置

作者: 只为踏雪寻梅    时间: 2011-05-24 11:17
回复 9# xiaopan3322


    我试过把Makefile里面的$OB_REL直接换成绝对路径,但是出现下面的问恩
Makefile:8: /root/result/etc/Tmp.mk: Permission denied
Makefile:59: /root/result/etc/CALLmake: Permission denied

但是我在/root/result/etc/下面对着两个文件都是chmod 777的  这也是我到现在死活都想不明白的地方!
作者: xiaopan3322    时间: 2011-05-24 11:24
回复 11# 只为踏雪寻梅


1. 运行以下命令,把信息贴出来:
ls -l /root/result/etc/Tmp.mk
ls -l /root/result/etc/CALLmake

2. 你的Hudson是以什么用户来起的?root?
作者: 只为踏雪寻梅    时间: 2011-05-24 11:28
回复 12# xiaopan3322


    [root@rhel142 etc]# ls -tlr Tmp.mk
-rwxrwxrwx 1 hudson hudson 1107 May 23 14:14 Tmp.mk
[root@rhel142 etc]# ls -tlr CALLmake
-rwxrwxrwx 1 hudson hudson 40613 May 23 14:14 CALLmake

我是在root用户下面启动hudson的  
[root@rhel142 etc]# ps -ef|grep hudson
root     26321     1  0 May23 ?        00:00:00 runuser -s /bin/bash - hudson -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/bin/java -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
hudson   26322 26321  0 May23 ?        00:00:00 -bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /usr/bin/java -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
hudson   26346 26322  0 May23 ?        00:01:05 /usr/bin/java -Djava.awt.headless=true -DHUDSON_HOME=/var/lib/hudson -jar /usr/lib/hudson/hudson.war --logfile=/var/log/hudson/hudson.log --httpPort=8080 --debug=5 --handlerCountMax=100 --handlerCountMaxIdle=20
root     29804 28789  0 11:27 pts/0    00:00:00 grep hudson
作者: xiaopan3322    时间: 2011-05-24 11:42
本帖最后由 xiaopan3322 于 2011-05-24 11:43 编辑

回复 13# 只为踏雪寻梅


    为啥会有三个进程?而且为啥三个的端口都是一样的,都是8080?你用的是哪个,我注意到后面的两个是以hudson这个用户起的……
    如果你用的是后者,并且你能确定给/root目录开权限没有问题的话,试试下面的:
    chmod -R 777 /root
    然后再试试

    要么把这两个文件放到别的地方去
作者: 只为踏雪寻梅    时间: 2011-05-24 12:36
回复 14# xiaopan3322


    好的!谢了兄弟!
作者: xiaopan3322    时间: 2011-05-24 12:40
回复 15# 只为踏雪寻梅


    先别谢了,我关心的是,问题解决了吗?
作者: 只为踏雪寻梅    时间: 2011-05-24 14:07
回复 16# xiaopan3322


    我的QQ是424768587   方便的话QQ上说下!
作者: 只为踏雪寻梅    时间: 2011-05-24 15:06
Dear ALL:
     该贴问题已经处理!因为编译需要用到环境变量OB_REL  但是hudson不认这个变量,所以在调用build脚本的时候找不到对应的路径。处理方法再系统管理的系统设置里面有个Environment variables  在这里加上OB_REL和对应的路径就可以了。谢谢xiaopan3322 (扛一肩记忆) 的帮助和指点!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2