Commit 9f18381a authored by Seweryn Zeman's avatar Seweryn Zeman

Added post_build_script to call after user build scripts

parent 1e3e4a29
......@@ -175,9 +175,10 @@ type RunnerSettings struct {
BuildsDir string `toml:"builds_dir,omitempty" json:"builds_dir" long:"builds-dir" env:"RUNNER_BUILDS_DIR" description:"Directory where builds are stored"`
CacheDir string `toml:"cache_dir,omitempty" json:"cache_dir" long:"cache-dir" env:"RUNNER_CACHE_DIR" description:"Directory where build cache is stored"`
Environment []string `toml:"environment,omitempty" json:"environment" long:"env" env:"RUNNER_ENV" description:"Custom environment variables injected to build environment"`
PreCloneScript string `toml:"pre_clone_script,omitempty" json:"pre_clone_script" long:"pre-clone-script" env:"RUNNER_PRE_CLONE_SCRIPT" description:"Runner-specific command script executed before code is pulled"`
PreBuildScript string `toml:"pre_build_script,omitempty" json:"pre_build_script" long:"pre-build-script" env:"RUNNER_PRE_BUILD_SCRIPT" description:"Runner-specific command script executed after code is pulled, just before build executes"`
Environment []string `toml:"environment,omitempty" json:"environment" long:"env" env:"RUNNER_ENV" description:"Custom environment variables injected to build environment"`
PreCloneScript string `toml:"pre_clone_script,omitempty" json:"pre_clone_script" long:"pre-clone-script" env:"RUNNER_PRE_CLONE_SCRIPT" description:"Runner-specific command script executed before code is pulled"`
PreBuildScript string `toml:"pre_build_script,omitempty" json:"pre_build_script" long:"pre-build-script" env:"RUNNER_PRE_BUILD_SCRIPT" description:"Runner-specific command script executed after code is pulled, just before build executes"`
PostBuildScript string `toml:"post_build_script,omitempty" json:"post_build_script" long:"post-build-script" env:"RUNNER_POST_BUILD_SCRIPT" description:"Runner-specific command script executed after code is pulled and just after build executes"`
Shell string `toml:"shell,omitempty" json:"shell" long:"shell" env:"RUNNER_SHELL" description:"Select bash, cmd or powershell"`
......
......@@ -35,13 +35,14 @@ func (s *ShellConfiguration) String() string {
}
type ShellScriptInfo struct {
Shell string
Build *Build
Type ShellType
User string
RunnerCommand string
PreCloneScript string
PreBuildScript string
Shell string
Build *Build
Type ShellType
User string
RunnerCommand string
PreCloneScript string
PreBuildScript string
PostBuildScript string
}
type Shell interface {
......
......@@ -33,21 +33,22 @@ This defines one runner entry.
| Setting | Description |
| ------- | ----------- |
| `name` | not used, just informatory |
| `url` | CI URL |
| `token` | runner token |
| `tls-ca-file` | file containing the certificates to verify the peer when using HTTPS |
| `tls-skip-verify` | whether to verify the TLS certificate when using HTTPS, default: false |
| `limit` | limit how many jobs can be handled concurrently by this token. 0 simply means don't limit |
| `executor` | select how a project should be built, see next section |
| `shell` | the name of shell to generate the script (default value is platform dependent) |
| `builds_dir` | directory where builds will be stored in context of selected executor (Locally, Docker, SSH) |
| `cache_dir` | directory where build caches will be stored in context of selected executor (Locally, Docker, SSH). If the `docker` executor is used, this directory needs to be included in its `volumes` parameter. |
| `environment` | append or overwrite environment variables |
| `disable_verbose` | don't print run commands |
| `output_limit` | set maximum build log size in kilobytes, by default set to 4096 (4MB) |
| `pre_clone_script` | commands to be executed on the runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. to insert multiple commands, use a (triple-quoted) multi-line string. |
| `pre_build_script` | commands to be executed on the runner after cloning the Git repository, but before executing the build. to insert multiple commands, use a (triple-quoted) multi-line string. |
| `name` | not used, just informatory |
| `url` | CI URL |
| `token` | runner token |
| `tls-ca-file` | file containing the certificates to verify the peer when using HTTPS |
| `tls-skip-verify` | whether to verify the TLS certificate when using HTTPS, default: false |
| `limit` | limit how many jobs can be handled concurrently by this token. 0 simply means don't limit |
| `executor` | select how a project should be built, see next section |
| `shell` | the name of shell to generate the script (default value is platform dependent) |
| `builds_dir` | directory where builds will be stored in context of selected executor (Locally, Docker, SSH) |
| `cache_dir` | directory where build caches will be stored in context of selected executor (Locally, Docker, SSH). If the `docker` executor is used, this directory needs to be included in its `volumes` parameter. |
| `environment` | append or overwrite environment variables |
| `disable_verbose` | don't print run commands |
| `output_limit` | set maximum build log size in kilobytes, by default set to 4096 (4MB) |
| `pre_clone_script` | commands to be executed on the runner before cloning the Git repository. this can be used to adjust the Git client configuration first, for example. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
| `pre_build_script` | commands to be executed on the runner after cloning the Git repository, but before executing the build. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
| `post_build_script` | commands to be executed on the runner just after executing the build, but before executing `after_script`. To insert multiple commands, use a (triple-quoted) multi-line string or "\n" character. |
Example:
......
......@@ -51,6 +51,7 @@ func (e *AbstractExecutor) generateShellConfiguration() error {
info := e.Shell()
info.PreCloneScript = e.Config.PreCloneScript
info.PreBuildScript = e.Config.PreBuildScript
info.PostBuildScript = e.Config.PostBuildScript
shellConfiguration, err := common.GetShellConfiguration(*info)
if err != nil {
return err
......
......@@ -379,6 +379,10 @@ func (b *AbstractShell) writeUserScript(w ShellWriter, info common.ShellScriptIn
commands := info.Build.Commands
b.writeCommands(w, commands)
if info.PostBuildScript != "" {
b.writeCommands(w, info.PostBuildScript)
}
return nil
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment