Intention is to run k6 inside an Azure DevOps pipeline using docker
k6 Docker is stored inside Artifactory :
I was successful to run, inside the pipeline, after writing following command inside yml file
" - script: docker run --rm -i
to get the output stored inside a json file getting error
" - script: docker run -i --rm
run --out json=/k6Report/my_test_result.json /K6PerformanceTesting/script.js"
time="2023-05-29T09:14:47Z" level=error msg="The moduleSpecifier \"/K6PerformanceTesting/script.js\" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container, see [https://k6.io/docs/using-k6/modules#using-local-modules-with-docker."](https://k6.io/docs/using-k6/modules#using-local-modules-with-docker.%22)
##[error]Bash exited with code '255'.
Folder structure is correct
Based on the error, the script is not found in your path.
The moduleSpecifier \"/K6PerformanceTesting/script.js\" couldn't be found on local disk. Make sure that you've specified the right path to the file. If you're running k6 using the Docker image make sure you have mounted the local directory (-v /local/path/:/inside/docker/path) containing your script and modules so that they're accessible by k6 from inside of the container.
And it points you to the docs to solve this: Modules, and we have an excellent example of the docker command in JSON.
This is a docker issue, more than a k6 one, and I as suche I’d recommend having a look at the docker documentation regarding mounting volumes: Bind mounts | Docker Documentation
I find this works if I try to execute something similar with docker locally. It’s a matter of correctly indicating where the scripts and output will be.
docker run --rm -i -v "$PWD:/K6PerformanceTesting" -v "$PWD:/k6Report" grafana/k6 run --vus 10 --duration 5s --out json=/k6Report/out.json /K6PerformanceTesting/script.js
This creates an
out.json in the
./k6Report directory (if it has write permissions), and also reads the
Once it works for you locally, this will probably also work on Azure DevOps. However, I did not test it.
I hope this helps.
Thanks it worked
docker run -i --rm
it also generated an xml