If you have functions in your build scripts, this is a strong sign, that you have too much imperative logic in your build scripts, and should maybe consider using convention plugins instead.
The problem with the function regarding CC is, that the function is defined on the script instance so to access the function you would need a reference to the script instance in CC and that is not allowed. If you really want to have it directly in the build script, move the function to a object you declare in the buildscript, this makes it "static" and independent from the build script instance and should then be callable CC compatible.