jenkinsamazon-ec2jenkins-pluginsec2-ami

What's the use of rootCommandPrefix in Amazon EC2 Jenkins plugin?


The ec2 plug-in for Jenkins offers the option to boot EC2 nodes from AMI to run jobs.

On its documentation it states that

If using an Ubuntu EC2 or UEC AMI you need to fill out the rootCommandPrefix and remoteAdmin fields under advanced.

But there's not a single example anywhere on how to actually use it. The images on docs show blanks on those fields

actual image from docs

Do anyone know what's the intended purpose? I'm trying to use a Ubuntu AMI but it fails due to permission issues and I guess this might be related.


Solution

  • The value of this parameter will be added as a prefix to all the commands that are executed on the spawned machine, and is not mandatory if you are suing the root user.
    From the help section:

    rootCommandPrefix
    This field is optional. It supplies a command prefix to use when running an administrative command, e.g. 'sudo'. This is needed when not using 'root' as a user (which is the typical case).

    Because your remote user is jenkins and not the root you will need to fill the rootCommandPrefix field with the value sudo to allow the privileged command execution to work.
    Without it you will probably encounter the permissions issues you are currently suffering from.