JetBrains Space Help

Run Shell Scripts

Using the shellScript keyword, you can run an arbitrary shell script. This could be a one-liner or a multiline script. The default script interpreter /bin/sh can be changed with interpreter.

For example:

job("run shell script") { container("ubuntu") { shellScript { interpreter = "/bin/bash" content = """ echo Hello echo World! """ } } }

If you want to run an existing script file (e.g., stored in the project repository), you should specify its location. It could be an absolute path, or a path that is relative to a working directory. If your script file requires arguments, you can provide them with the args function.

job("run shell script") { container("ubuntu") { shellScript { location = "./myscript.sh" args("arg1, arg2") } } }

Running a default image command

Alternatively to running a shell script, you can run a default image command. To run the default command, provide its arguments in the args array. Note that special characters must be escaped.

For example:

job("Example") { container("alpine") { args("echo", "Hello World!") } }

If you want to override the default image command, you can do this by using entrypoint. In this case, args provide arguments for the entrypoint command. Note that special characters must be escaped.

For example:

job("Example") { container("gradle:latest") { entrypoint("/bin/sh") args("echo", "Hello World!") } }

Last modified: 18 February 2021