Bug 1311426
Summary: | [devexp_public_844]Cannot implement post-build command when adding Command with arguments to bc and build | |||
---|---|---|---|---|
Product: | OKD | Reporter: | wewang <wewang> | |
Component: | Build | Assignee: | Rodolfo Carvalho <rcarvalh> | |
Status: | CLOSED CURRENTRELEASE | QA Contact: | Wenjing Zheng <wzheng> | |
Severity: | medium | Docs Contact: | ||
Priority: | medium | |||
Version: | 3.x | CC: | aos-bugs | |
Target Milestone: | --- | |||
Target Release: | --- | |||
Hardware: | Unspecified | |||
OS: | Unspecified | |||
Whiteboard: | ||||
Fixed In Version: | Doc Type: | Bug Fix | ||
Doc Text: | Story Points: | --- | ||
Clone Of: | ||||
: | 1311435 (view as bug list) | Environment: | ||
Last Closed: | 2016-05-12 17:12:59 UTC | Type: | Bug | |
Regression: | --- | Mount Type: | --- | |
Documentation: | --- | CRM: | ||
Verified Versions: | Category: | --- | ||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | ||
Cloudforms Team: | --- | Target Upstream Version: | ||
Embargoed: | ||||
Bug Depends On: | ||||
Bug Blocks: | 1311435 |
Description
wewang
2016-02-24 08:50:45 UTC
when I use : "postCommit": { "command": [ "/bin/sh", "-ic" ], "args": [ "bundle", "exec", "rake", "test" ] build is complete ,but logs have error: sh: cannot set terminal process group (-1): Inappropriate ioctl for device sh: no job control in this shell http://pastebin.test.redhat.com/351307 @rhcarvalho ,can you updated docs:https://github.com/PI-Victor/openshift-docs/blob/pi-victor/post_build_actions/dev_guide/builds.adoc#build-hooks? then merge because I saw post commit are not include "bundle exec"; and command: ["/bin/sh", "-c"] should be command: ["/bin/sh", "-ic"] ,right? when I updated bc below Add Command to bc and build "postCommit": { "command": [ "bundle", "exec", "rake", "test", "--verbose" ] } $oc start-build <bc> Check the log Actual results: I0224 09:06:43.877799 1 common.go:134] Running post commit hook with image wewang/ruby-sample-build-10:59791539 ... F0224 09:06:44.568459 1 builder.go:204] Error: build error: start container "openshift_s2i-build_ruby-sample-build-10_wewang_post-commit": API error (404): Cannot start container 62f8bad2d5b107a80b81396de4d4005b3e3e9ed515f71eb1071b8c7b4b9b7c96: [8] System error: exec: "bundle": executable file not found in $PATH @wewang thanks for the report. 1. Docs You are right, the docs need to be updated. I've asked Victor who is leading the PR, I would like to get it cleaned up today. 2. Syntax There are multiple ways to run the tests if you are using the command/args syntax. For example, you can use Bash (then no need for -i): "command": ["/bin/bash", "-c", "bundle exec rake test"] Or, alternatively (with the Ruby image, since this relies on the image entrypoint): "args": ["bundle exec rake test"] (I'm updating the sample-app to use this as example, see https://github.com/openshift/origin/pull/7567) I will comment on the values you tried to use and why they didn't work: a. "postCommit": { "command": ["/bin/sh", "-ic"], "args": ["rake", "test"] } This doesn't work because "rake" and "test" are passed as separate arguments, so only "rake" is executed and it fails ("rake aborted!"), the "test" part is ignored. Example: $ /bin/sh -ic "echo 123" this will be ignored 123 The example above, written with the command/args syntax is: "command": ["/bin/sh", "-ic", "echo 123", "this", "will", "be", "ignored"] Notice that command + args is the same as having only command with empty value for args, IOW: {"command": ["/bin/bash"], "args": ["/my/script"]} == {"command": ["/bin/bash", "/my/script"]} b. "postCommit": { "command": ["/bin/sh", "-ic"], "args": ["bundle", "exec", "rake", "test"] Same problem with args, should be a single string: {"command": ["/bin/sh", "-ic"], "args": ["bundle exec rake test"]} c. "postCommit": { "command": ["bundle", "exec", "rake", "test", "--verbose"] } In this case, the Ruby image doesn't have "bundle" in the PATH by default ('"bundle": executable file not found in $PATH'). That's a known limitation of our SCL images, that need the appropriate SCLs to be enabled before you can use them. We try to make it better by automatically enabling collections when: i. `/bin/bash` is used ii. `/bin/sh -ic` is used In all other cases, `scl enable ruby200` (depends on exact version) is needed. That's why the script syntax uses `/bin/sh -ic`. I didn't try, but something like this should work as well: {"command": ["scl", "enable", "ruby200", "bundle", "exec", "rake", "test", "--verbose"]} (might be missing something or have wrong collection name) @ Rodolfo Carvalho thanks for your detail comments I already see docs has been updated and verified below sceniaros , it all works verified version: openshift v1.1.3-271-g28e5bbf-dirty kubernetes v1.2.0-alpha.7-703-gbc4550d etcd 2.2.5 a.b. updated postCommit with command and args command: ["bundle", "exec", "rake", "test"] args: ["--verbose"] c. updated postCommit with command, "bundle exec rake test --verbose" is a single args : command: ["/bin/bash", "-c", "bundle exec rake test --verbose"] the bug already verified now, you can set the bug to assigned, if docs pr is merged ,will accept related card ,thanks for your quick response. |