Let's say I have two directories, lib
and src
, and only want Codeship to build commited changes that are from the src
directory. How would I go about making a Bash script that does that? I know that applying the --skip-ci
flag to a commit will make Codeship not create a build off of that commit. Any help is greatly appreciated!

- 1,415
- 1
- 13
- 33
2 Answers
Im not familiar with Codeship but if you are a git user you can do one of the following:
- Use the src/lib as
submodules
and then any time someone commit to any of those folders execute the commit - Use a git hook to find out if someone has committed to those directories and then execute commit based upon the desired folder.
for example add this line to any of your commit hook
if [ $(git diff --name-only HEAD^..HEAD path/ ) ]
and check to see if this is a true.

- 128,036
- 21
- 144
- 167
You could use a command like the following directly in the test steps:
if [[ $(git log -m -n 1 --name-only --pretty=format:"" | grep -e "lib" -e "src" -c) -gt 0 ]]; then run_your_tests; fi
This will display the changed files for the last commit without any additional metadata and count the occurrences of lib
and src
in those lines.
If these strings occur more than once it will run the run_your_tests
command. Else it will simply return.
Note, that this is a very crude version, it isn't looking for the strings at the beginning of file names for example. But it should be a good starting point.
Please get in touch via support@codeship.com (or our in app messenger) if you have any further questions! (And I will update the answer if we add something via the in app support.
[Disclaimer] I'm working for Codeship ;)

- 766
- 5
- 11
-
1Interesting. What would be really amazing for CodeShip to have is a repo file browser (kind of like what GitHub) that has checkboxes beside each file and directory. Each one that's checked would start a build whenever changes are made to or inside of said file! Anyway, I just want CodeShip to make builds whenever changes are made to the `src` directory only. Everything else should be ignored. How would I do that? – T145 Feb 11 '15 at 16:01
-
You would need to remote the `-e "lib"` part from the above snippet and add this to your test steps. (And of course adapt the `run_your_tests` command accordingly. – mlocher Feb 12 '15 at 10:17