Strider-CD / strider-docker-runner

Strider runner that uses Docker
34 stars 19 forks source link

doesn't work with gitlab provider #17

Closed kfatehi closed 8 years ago

kfatehi commented 10 years ago

ive been trying to debug this for awhile -- it's not leading me anywhere fruitful. im thinking @jaredly maybe you'll be able to push me in the right direction on this one. I'm resorting to testing outside of docker for now.

 git clone --recursive git@gitlab.knban.com:sbox/sbox.git . -b master gitlab 576ms -1
Cloning into '.'...
$ git checkout -qf master gitlab 31ms -1
fatal: Not a git repository (or any of the parent directories): .git
$  -1
An unexpected error occurred while executing this job. Please report at https://github.com/Strider-CD/strider/issues

Checkout failed with code 128

Error: Checkout failed with code 128
    at badCode (/opt/strider/node_modules/strider-gitlab/node_modules/strider-git/worker.js:88:11)
    at /opt/strider/node_modules/strider-gitlab/node_modules/strider-git/worker.js:120:22
    at EventEmitter.<anonymous> (/opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/lib/job.js:203:9)
    at EventEmitter.emit (events.js:95:17)
    at /opt/strider/node_modules/strider-docker-runner/lib/create-container.js:72:18
    at Stream.write (/opt/strider/node_modules/strider-docker-runner/node_modules/event-stream/index.js:192:22)
    at Stream.stream.write (/opt/strider/node_modules/strider-docker-runner/node_modules/event-stream/node_modules/through/index.js:26:11)
    at Stream.ondata (stream.js:51:26)
    at Stream.emit (events.js:95:17)
    at Stream.<anonymous> (/opt/strider/node_modules/strider-docker-runner/node_modules/event-stream/index.js:239:12)
Error: Checkout failed with code 128
Error: Error: Checkout failed with code 128
    at /opt/strider/node_modules/strider-docker-runner/lib/run.js:30:21
    at Object.Job.done (/opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/lib/job.js:125:5)
    at Object.Job.phaseDone (/opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/lib/job.js:311:21)
    at /opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/node_modules/async/lib/async.js:232:13
    at /opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/node_modules/async/lib/async.js:136:21
    at /opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/node_modules/async/lib/async.js:229:17
    at /opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/node_modules/async/lib/async.js:556:34
    at /opt/strider/node_modules/strider-gitlab/node_modules/strider-git/worker.js:120:5
    at EventEmitter.<anonymous> (/opt/strider/node_modules/strider-docker-runner/node_modules/strider-runner-core/lib/job.js:203:9)
    at EventEmitter.emit (events.js:95:17)
Dids commented 9 years ago

+1 Any news on this?

leutrimhusaj commented 9 years ago

:+1: it would be cool if someone checks this error

knownasilya commented 9 years ago

@Dids @leutrimhusaj do you guys see the same errors? Are you using the hosted gitlab or community edition? What version of gitlab? What version of strider and this plugin, and strider-gitlab plugin.

leutrimhusaj commented 9 years ago

@knownasilya yep i'm getting the same error Community Edition GitLab 7.7.1 strider 1.6.0-pre.2 strider-gitlab 1.0.5

knownasilya commented 9 years ago

@leutrimhusaj can you update strider to latest (1.6.3) and give it a try (most likely wont fix it, but worth ruling things out).

leutrimhusaj commented 9 years ago

@knownasilya tried it out but it doesn't work :/

leutrimhusaj commented 9 years ago

@knownasilya i'm using strider and gitlab in two docker containers, does it make a difference?

leutrimhusaj commented 9 years ago

@knownasilya you had time to have a look at this issue?

knownasilya commented 9 years ago

@leutrimhusaj nope, but if you have them in two docker containers, you need to link them somehow, so that strider has access to the gitlab server..

leutrimhusaj commented 9 years ago

@knownasilya which one? the strider and gitlab-docker, or the strider-docker-slave and the gitlab-docker? But the error only appears when i use the strider-docker-slave...the standard-runner works, even when the containers are not linked...the sources are checked out just via the url.

chengweiv5 commented 9 years ago

I'm running into this issue too. And I changed some code to debug.

/data/strider/data/yangchengwei-strider-demo-55b5ffcb0ce1df3f0529223d

However, after I enter into the container(docker exec -it /bin/bash), I found that there even not /data directory at all, neither /data/strider/data/yangchengwei-strider-demo-55b5ffcb0ce1df3f0529223d where the following git checkout was trying to work in.

So I'm wondering if git clone running in the container started by strider-docker-runner?

chengweiv5 commented 9 years ago

update: I found that it did run some commands in the strider-docker-slave container started by strider-docker-runner, however, seems the gitlab clone code doesn't run in container? See below logs:

strider stdout | 2015-07-28T01:41:44.720Z - info: Tue, 28 Jul 2015 01:41:44 GMT strider-docker-runner:create-container image is already locally
strider stdout | 2015-07-28T01:41:45.055Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container [runner:docker] container id 7706a19783e46d1d25a0f302bf627df6f9d1e433ce16f5bae24d40e1500e08ed
strider stdout | 2015-07-28T01:41:45.224Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container running command sh
strider stdout | 2015-07-28T01:41:45.224Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container with args [ '-e', '-x', '-c', 'env' ]
strider stdout | 2015-07-28T01:41:45.459Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container got an event { event: 'stdout',
  data: 'MAIL=/var/mail/strider\nUSER=strider\nHOSTNAME=7706a19783e4\nSHLVL=1\nHOME=/home/strider\nLOGNAME=strider\n_=/usr/local/bin/strider-docker-slave\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games\nSHELL=/bin/bash\nPWD=/home/strider/workspace\n' }
strider stdout | 2015-07-28T01:41:45.461Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container got an event { event: 'stderr', data: '+ env\n' }
strider stdout | 2015-07-28T01:41:45.464Z - info: Tue, 28 Jul 2015 01:41:45 GMT strider-docker-runner:create-container got an event { code: 0, event: 'exit' }
strider stdout | 2015-07-28T01:41:45.582Z - info: Git Version:1.9
strider stdout | 2015-07-28T01:41:48.661Z - info: Job 55b6ddd79814ac2c00b7efaf  gitlab gitane command done git clone --recursive ssh://git@gitlab.localdomain:10022/yangchengwei/demo.git . --branch master; exit code 0; duration 3179
strider stdout | 2015-07-28T01:41:48.681Z - info: Tue, 28 Jul 2015 01:41:48 GMT strider-docker-runner:create-container running command git
strider stdout | 2015-07-28T01:41:48.681Z - info: Tue, 28 Jul 2015 01:41:48 GMT strider-docker-runner:create-container with args [ 'checkout', '--quiet', '--force', 'master' ]
strider stdout | 2015-07-28T01:41:48.687Z - info: Tue, 28 Jul 2015 01:41:48 GMT strider-docker-runner:create-container got an event { event: 'stderr',
  data: 'fatal: Not a git repository (or any of the parent directories): .git\n' }
knownasilya commented 9 years ago

Thanks for trying to dig into this. I'm not seeing how the logs show that it's not run in the container.

knownasilya commented 9 years ago

Ah, the environment variables..

dmouse commented 8 years ago

I have the same error, I'm using docker + gitlab and the strider/strider-docker-slave image

prepare -1
$ git clone --recursive ssh://git@chev.com:2222/root/ci-sample.git . --branch master gitlab 690ms -1
Cloning into '.'...
$ git checkout --quiet --force master gitlab 18ms -1
fatal: Not a git repository (or any of the parent directories): .git
chriz2600 commented 8 years ago

I did some research on this topic: Initial "git clone" is not executed inside the docker container - as someone mentioned before. Source is cloned to "/home/strider/.strider/data/[job-id]/" (i think mainly, because it uses gitane for ssh checkout, with a different process/spawn context). The following git checkout is executed via the context.cmd function, which is inside the docker container (directory is /home/strider/workspace). Inside the gitaneCmd function context.runCmd is used to set the spawn function for gitane.run, but context.runCmd is undefined in this context.

sebas5384 commented 8 years ago

same error here, but seems to be a problem with private repos.

sebas5384 commented 8 years ago

Seems to be related with https://github.com/Strider-CD/strider-docker-runner/issues/36#issuecomment-162159044

chriz2600 commented 8 years ago

Hi,

git checkout via ssh is currently not working with strider-docker-runner. The reasons for that: In strider-git lib/index.js context.runCmd is passed to gitane as spawn function, but context.runCmd is undefined in this context. Even if it may contain the spawn function from config, it would not work, because the config.spawn API and nodejs spawn API differs. I created a solution, but it requires some packages to be changed:

How to test: In a running strider installation, go to the main strider directory and execute:

# npm dedupe strider-git
# npm dedupe strider-runner-core
# npm install chriz2600/strider-docker-gitane-camo
# npm install chriz2600/strider-git
# npm install chriz2600/strider-runner-core

Restart strider. Setup a project either via 'Manual add' (be sure to choose SSH for 'Repository Authentication') or via gitlab integration. Be sure to choose 'chriz2600/strider-docker-slave' as docker image in 'Runner: Docker' configuration.

Currently the main drawback is, that context.cmd could not be set to 'silent' when invoking, so your ssh private key is shown in build output.

Links: https://github.com/chriz2600/strider-docker-gitane-camo https://github.com/chriz2600/strider-git https://github.com/chriz2600/strider-runner-core https://github.com/chriz2600/strider-docker-slave

knownasilya commented 8 years ago

@chriz2600 feel free to submit PRs where ever you see necessary.

knownasilya commented 8 years ago

@chriz2600 what's the status on this issue?

chriz2600 commented 8 years ago

Currently it's just running fine, the only downside still is that the ssh key is visible in the build log.

knownasilya commented 8 years ago

No changes were necessary to this repo?

chriz2600 commented 8 years ago

The changes made on Dec 9, 2015 should do the job.

knownasilya commented 8 years ago

Ah, so everything that was changed was in other repos, ok.

mandoz commented 8 years ago

@chriz2600 @knownasilya this issue still persists. I reinstalled everything fresh using the latest versions of everything. I think its because the latest release or runner core is outdated: https://github.com/Strider-CD/strider-runner-core/releases

knownasilya commented 8 years ago

Working on updating that https://github.com/Strider-CD/strider-runner-core/issues/13

knownasilya commented 8 years ago

@mandoz I published 2.0.1 or runner-core, can you try again?

mandoz commented 8 years ago

@knownasilya that fixed it! Thank you very much :)