Strider-CD / strider-custom

Support for custom prepare, test and deploy phases in Strider
9 stars 7 forks source link

Configurable sh -l (login shell) for command execution #9

Open morkeleb opened 10 years ago

morkeleb commented 10 years ago

I wanted to set up a custom script to ensure a specific ruby version and run my ruby tests. However, when the scripts are run there are no bash variables imported.

So after a while I figure out I could do something similar to this:

bash --login -c "rvm use 1.9.3; bundle exec rspec"

If the strider-custom.json could also contain a shell arguments and shell option that could be used in process I'm free to choose my own shell and thus be able to import variables based on the user running strider. Making it much easier to start using Strider with other languages.

example:

{
  "command": 'bash',
  "args": ['-x', '-c', '--login', command]
  "prepare": "echo executed prepare statement!",
  "test": "echo executed deploy statement!",
  "deploy": "echo deploy && git push heroku master --force"
}

In theory this could also open up for use with other environments such as powershell on Windows.

niallo commented 10 years ago

We don't stop you from using your own shell, you can always spawn it yourself.

E.g. your command itself could be "/bin/sh -l -c foo"

Test and deploy scripts shouldn't really depend on the presence of bash variables on your particular machine. We could look into making login shell configurable though (e.g. /bin/sh -l -c rather than /bin/sh -c)

morkeleb commented 10 years ago

I might not have been entirely clear. I run rvm using --login as its own command right now, so things are working.

Configurable is what I'm looking for.

Unfortunately RVM requires all sorts of functions and paths set, and currently is one of the easiest ways to have a linux server configured for ruby. With an option for configuring login I can keep my custom scripts a lot more readable.

niallo commented 10 years ago

Ok, I understand. I updated the title of the issue to reflect that.

On another note - how is Ruby working for you with Strider? We'd love to have a strider-ruby plugin, which might make more sense for 80% of cases, rather than strider-custom. Similar to what we have for Node and Python today.

What do you think?

morkeleb commented 10 years ago

it works great execpt that I have to use the login. This is what my config looks like:

{
  "prepare": "bash --login -c \"rvm use 1.9.3; bundle install\"",
  "test": "bash --login -c \"rvm use 1.9.3; bundle exec rspec\" && karma start --single-run"
}

which runs all my rspec tests using rspec and then if that works it runs all my jasmine tests using karma.

Native plugin would be nice, especially if it can "auto detect" which types of tests to run. But that means tackling the whole rvm issue. Having rvm support "built in" would be nice since it would allow specifying different ruby versions per project, but its heavily dependent on the users profile.

So far, except for some minor gotchas strider has been nice to work with. I find it easier to set up than Jenkins. Specially since the github integration is taken care of already. I think there is a niche for building using nodejs, I hope strider manages to fill it :)

niallo commented 10 years ago

I'm glad you find Strider nice! It looks like you're on 1.3.5 (latest stable).

We're finishing up 1.4.0 which greatly improves strider-custom (in addition to supporting bitbucket, github enterprise, pull requests and branches). If you'd like to take it for a spin, try cloning HEAD of the main strider repo and running on the master branch.

You might like it :)

morkeleb commented 10 years ago

I just installed HEAD from the master branch. I quickly ran into some bugs that prevent me from trying things out. I added them as separate issues, I hope that helps.

faraazkhan commented 10 years ago

+1 for the native ruby plugin

filipechagas commented 10 years ago

+1 I have database and some other app info configured using environment vars. Using the bash --login -c approach, I have to export the vars, inline, every single command line,

knownasilya commented 9 years ago

Is this issue still present?

knownasilya commented 8 years ago

There is not an option to select a shell, feel free to add additional shells. There are no arguments though.