linuxsystemdbitbucket-pipelinessystemctl

bitbucket pipeline : systemctl (systemd)


I have looked around, and I am afraid it's not possible, but maybe someone has an idea or some kind of workaround:
Is there any way to run services via systemctl on a bitbucket pipeline ?

I have code that generates service files and runs them via systemctl. I want to automate some tests by running that code which specifically calls systemctl.

typically, is it possible to run, on a pipeline, smth like this code:

serviceCmd = "sudo systemctl start " + serviceName;
std::system(serviceCmd) 

any help would be appreciated Thanks


Solution

  • Adding this for any future people who might ask themselves the same:

    As it happens, on Ubuntu 20 and Ubuntu 22 (not on CentOS 7.9 noor Ubuntu 18 though), you can simply install systemctl via

    sudo apt-get install systemctl -y
    

    And any usage of systemctl seems to be working. I had to add a little hack though because I kept having an error message stating

    ERROR:systemctl: man-db.service: Executable path is not absolute, ignoring: +/usr/bin/install -d -o man -g man -m 0755 /var/cache/man
    

    To fix this, I did this in my DockerFile

    [ -f /lib/systemd/system/man-db.service ] && sed -i 's/^\(ExecStart=+\)/ExecStart=/' /lib/systemd/system/man-db.service
    

    so basically remove the + sign in the man-db.service file