How runners work?
epiphyllum opened this issue · 5 comments
I have set up gitlab, gitlab-ci, and runner-gitlab.
In my gitlab, I have a simple project called perl-private, in this project, I have only one file: hello.sh
hello.sh
#/!bin/bash
echo "hellol world"
echo "hello world";
and I set the buildscript in GitLab-CI for this project like this:
build script
./hello.sh > hello.log 2>&1
then I go to my wokring box and push some changes to gitlab, the ci is immediately triggered.
but the result is failed. and I check the hello.log in the runner. got this message
/tmp/executor20150401-21-1lf9trp: line 9: ./hello.sh: No such file or directory
so I just wonder how those runner works?
(gitlab.com)[https://gitlab.com/gitlab-org/gitlab-ci/blob/master/doc/examples/build_script_gitlab_ce.md]
said: runner runs the line below before it runs the commands in your build script
cd /gitlab-ci-runner/tmp/builds
git clone git@gitlab_server_fqdn:group/project.git project-1
cd project-1
git checkout master
but why the runner complain that ./hello.sh No such file or directory??
how runner works?
@epiphyllum maybe hello.sh
does not have exec permissions. you can try bash hello.sh
instead
@epiphyllum alternately you can add pwd
and ls -l
commands to the build script to get a better idea of whats going on.
I test it . and even see final buildscript with
pwd > run.log
echo $0 >> run.log
cat $0 > buildscript
then I got run.log
/home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds
/tmp/executor20150401-21-fggh4t
and buildscript
#!/bin/bash
set -e
trap 'kill -s INT 0' EXIT
echo cd\ /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds\ \&\&\ git\ clone\ http://gitlab-ci-token:b927e656bc4b5fbf32a4a4e06862c7@gitlab.tfs.com/root/perl-private.git\ project-2\ \&\&\ cd\ project-2\ \&\&\ git\ checkout\ 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds && git clone http://gitlab-ci-token:b927e656bc4b5fbf32a4a4e06862c7@gitlab.tfs.com/root/perl-private.git project-2 && cd project-2 && git checkout 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
echo cd\ /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-2\ \&\&\ git\ reset\ --hard\ \&\&\ git\ checkout\ 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-2 && git reset --hard && git checkout 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
echo pwd\ \>\ \ run.log
pwd > run.log
echo echo\ \$0\ \>\>\ run.log
echo $0 >> run.log
echo cat\ \$0\ \>\ buildscript
cat $0 > buildscript
so the runner will generate an script at /tmp/executor20150401-21-fggh4t
and run at directory /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds
but if you take a close look at this buildscript. execept those echo cmd; the final effective buildscript is
set -e
trap 'kill -s INT 0' EXIT
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds
&& git clone http://gitlab-ci-token:b927e656bc4b5fbf32a4a4e06862c7@gitlab.tfs.com/root/perl-private.git project-2
&& cd project-2 && git checkout 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
cd /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-2
&& git reset --hard
&& git checkout 2bdaaabc9b53c7fc2054255c001ce3cb61e94209
pwd > run.log
echo $0 >> run.log
cat $0 > buildscript
then comes to my another question,
when this script runs to pwd > run.log
, the current directory should be /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds/project-2
; but in run.log we see, the current directory is /home/gitlab_ci_runner/gitlab-ci-runner/tmp/builds
;
can you explain it??
I just wonder how to write an buildscript to CI my perl project. if my perl project t like this:
my project filetree
t/
lib/
bin/
Makefile.PL
README.md
changes.txt
run tests like this
perl Makefile.PL
make
make test
@epiphyllum sorry. I have not created build scripts using perl.