Closed e-picas closed 6 months ago
With the following YML:
my_job: image: node:lts script: - echo 'test'
I have the following --preview rendering:
--preview
$ node ../test-gitlab-ci-local/gitlab-ci-local/src/index.js --preview --- stages: - .pre - build - test - deploy - .post my_job: image: name: node:lts docker: user: null script: - echo 'test'
Which does not pass the ci/lint GitLab API route validation because docker.user can only be a string (and it's comprehensible, linux user null can not exist):
ci/lint
docker.user
null
$ jq --null-input --arg yaml "$(node ../test-gitlab-ci-local/gitlab-ci-local/src/index.js --preview)" '.content=$yaml' \ | curl "https://gitlab.com/api/v4/projects/${PROJECT_ID}/ci/lint" \ --header "Authorization: Bearer ${GITLAB_TOKEN}" \ --header 'Content-Type: application/json' \ --data @- | jq '.errors' [ "jobs:my_job:image executor opts '/docker/user' must be a valid 'string'" ]
The image.docker.user should not be rendered if it does not have a (string) value.
image.docker.user
I can see in the code it's a recent new feature: https://github.com/firecow/gitlab-ci-local/blame/master/src/data-expander.ts#L166. I think a simple verification of the existence of the value can be enough to fix this.
Ubuntu gitlab-ci-local master (not released for now)
Minimal .gitlab-ci.yml illustrating the issue
With the following YML:
I have the following
--preview
rendering:Which does not pass the
ci/lint
GitLab API route validation becausedocker.user
can only be a string (and it's comprehensible, linux usernull
can not exist):Expected behavior
The
image.docker.user
should not be rendered if it does not have a (string) value.I can see in the code it's a recent new feature: https://github.com/firecow/gitlab-ci-local/blame/master/src/data-expander.ts#L166. I think a simple verification of the existence of the value can be enough to fix this.
Host information
Ubuntu gitlab-ci-local master (not released for now)