Integrations with Jenkins

Hi All,

I am doing a POC for k6. So i wanted to integrate k6 in jenkins to see what all i can do with it. But i am facing issues while doing that. When i use below

Getting a error of sudo not found as i am not having elevated permissions. Found few articles in which i have change the file with nopassword in /etc/sudoers but i cannot do that nor i am having permission and its security issue.

Second is using k6 operator: But for POC not a good idea to setup.

Any other simple way that you guys can suggest to start off?


Just to add I am using kuberentes pods as executor in Jenkins.

Hi @apal,

You might only need sudo to install k6 if you use the APT repository. Instead, you can download the binary of the latest release and set execute permission on the binary (without using sudo) and just use it normally, thereby skipping and all sudo commands in the Jenkinsfile.

For the pods, I think @olha knows better.

:thinking: In addition to Mostafa’s suggestion, if you have a kubernetes plugin, perhaps it’s possible to build a Docker image with k6 already installed and use that instead?

As for k6-operator. AFAIK, we don’t have a ready-made tutorial for k6-operator + Jenkins but it should be relatively straight-forward to adapt this LINE tutorial that Amit posted, specifically this part:

          for (int i = 0; i < params.POD_COUNT.toInteger(); i++) {
            stages[i] = {
              node('k6node') {
                stage("Stage-${i}") {
                  container('k6') {

In case of k6-operator, you don’t need to start any nodes or pods but only apply the yaml file with configuration. IMHO, it is simpler than what LINE is doing, but it really depends on specific requirements for your POC.

Hope that helps!

Thanks @olha and @mostafa for reply.

@olha I am working on the same line tutorial link. Thanks for the suggestion. Will get back if I stuck anywhere :slight_smile:

Hi @olha and @mostafa,

I have followed the line article and after doing some modification able to run k6 as container but doing all the hard work getting below jenkins error. Again related to permission.

Can you please look at the error and suggest?


I have resolved the above one with a tweak. Thanks for the help.

Glad you could make it work. What was the tweak?

@mostafa In my case I have added a line runAsUser: 1000 (# default UID of Jenkins user in agent image) in securitycontext section of yaml. After that there was no permission issue and test executed successfully.

1 Like