gogitlab-cicicdk6xk6-browser

xk6 Prometheus remote write fails with go error


I am trying to use xk6 prometheus remote write to send k6 data.

In GitLab pipeline trying to install xk6 on golang image but it fail with go error with some version issue.

GitLab job

run:k6:
  stage: run
  environment: DEV
  variables:
    GIT_CHECKOUT: "false"
  image:
    name: golang
  needs:
    - job: build:k6
  script:
    - go install go.k6.io/xk6/cmd/xk6@latest
    - xk6 build --with github.com/grafana/xk6-output-prometheus-remote@latest
    - ./k6 run -o experimental-prometheus-rw --tag testid=test build/script.js
  artifacts:
    reports:
      junit: junit.xml
  when: manual

Getting below error while running pipeline

go: downloading google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f
2023/07/19 12:50:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
2023/07/19 12:50:56 [INFO] Writing main module: /tmp/buildenv_2023-07-19-1250.1174414957/main.go
2023/07/19 12:50:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod edit -require go.k6.io/k6@0.44.1 
2023/07/19 12:50:56 [INFO] exec (timeout=0s): /usr/local/go/bin/go mod tidy -compat=1.17 
go: errors parsing go.mod:
/tmp/buildenv_2023-07-19-1250.1174414957/go.mod:27:2: require go.k6.io/k6: version "0.44.1" invalid: unknown revision 0.44.1
2023/07/19 12:51:01 [INFO] Cleaning up temporary folder: /tmp/buildenv_2023-07-19-1250.1174414957
2023/07/19 12:51:01 [FATAL] exit status 1

Tried to check with different version of golang image like 1.19 and xk6 version also but same error persist.


Solution

  • Here is the reason of failure pipeline was having a variable like:

    variables:
      K6_VERSION: "0.44.1"
    

    which was used when I run

    xk6 build --with github.com/grafana/xk6-output-prometheus-remote@latest
    

    No idea how this was overriding, but after renaming/removing this variable it works.