Creating a artifacts:reports:dotenv fails when job is run manually with variable supplied in Trigger this manual action
Summary
Creating a dotenv artifact report fails if the job is manually triggered and the variable used in the dotenv report is added in the UI of job. If the variable is added as a CI/CD variable, or as a variable in the "Run pipeline" window, the job succeeds. If the variable is added (or changed) in the manual job above the button "Trigger this manual action", the job fails with responseStatus=500 Internal Server Error status=500.
Steps to reproduce
Gitlab server: 14.2.4-ee Gitlab runners: 14.2.0
- Have gitlab-runners with support for Windows docker (tag: windows2019-build-in-docker) or linux docker (tag: linux-docker)
- Use .gitlab-ci.yml from example below.
- Trigger the manual job and overwrite the DEPLOY_VERSION above the button "Trigger this manual action".
Example Project
.gitlab-ci.yml
input:deploy:env:windows:
stage: build
image: mcr.microsoft.com/windows/servercore:ltsc2019
tags:
- windows2019-build-in-docker
variables:
DEPLOY_VERSION: 'default'
script:
- write-host "$env:DEPLOY_VERSION"
- $ENVFILE = "variable.env"
- 'If (Test-Path $ENVFILE) { Remove-Item $ENVFILE }'
- Add-Content -Path $ENVFILE -Value "DEPLOY_VERSION=$env:DEPLOY_VERSION"
- Get-Content -Path $ENVFILE
artifacts:
reports:
dotenv: variable.env
needs: []
when: manual
input:deploy:env:linux:
stage: build
image: mcr.microsoft.com/powershell
tags:
- linux-build-in-docker
variables:
DEPLOY_VERSION: 'default'
script:
- pwsh -f ./create_env.ps1
artifacts:
reports:
dotenv: variable.env
needs: []
when: manual
create-env.ps1 contents
write-host "$env:DEPLOY_VERSION"
$ENVFILE = "variable.env"
If (Test-Path $ENVFILE) { Remove-Item $ENVFILE }
Add-Content -Path $ENVFILE -Value "DEPLOY_VERSION=$env:DEPLOY_VERSION"
Get-Content -Path $ENVFILE
What is the current bug behavior?
Job fails with error and uploading the artifacts as dotenv to coordinator fails with responseStatus=500.
What is the expected correct behavior?
Job succeeds and artifact is created.
Relevant logs and/or screenshots
Example log of failed job, where DEPLOY_VERSION was set above the button Trigger this manual action
$ pwsh -f ./create_env.ps1 triggerthismanualaction DEPLOY_VERSION=triggerthismanualaction Uploading artifacts for successful job 00:05 Uploading artifacts... variable.env: found 1 matching files and directories WARNING: Uploading artifacts as "dotenv" to coordinator... failed id=806371 responseStatus=500 Internal Server Error status=500 token=XXXXX WARNING: Retrying... context=artifacts-uploader error=invalid argument WARNING: Uploading artifacts as "dotenv" to coordinator... failed id=806371 responseStatus=500 Internal Server Error status=500 token=XXXXX WARNING: Retrying... context=artifacts-uploader error=invalid argument WARNING: Uploading artifacts as "dotenv" to coordinator... failed id=806371 responseStatus=500 Internal Server Error status=500 token=XXXXX FATAL: invalid argument Cleaning up file based variables 00:00 ERROR: Job failed: exit code 1Example of succesful log, when the DEPLOY_VAR is not supplied in the Trigger this manual action window
$ pwsh -f ./create_env.ps1 default DEPLOY_VERSION=default Uploading artifacts for successful job 00:01 Uploading artifacts... variable.env: found 1 matching files and directories Uploading artifacts as "dotenv" to coordinator... ok id=806357 responseStatus=201 Created token=XXXXX Cleaning up file based variables 00:01 Job succeededNote that it also succeeds if you overwrite the variable in the "Run pipeline" window
Variable set in Run pipeline window
$ pwsh -f ./create_env.ps1 runpipeline DEPLOY_VERSION=runpipeline Uploading artifacts for successful job 00:00 Uploading artifacts... variable.env: found 1 matching files and directories Uploading artifacts as "dotenv" to coordinator... ok id=806373 responseStatus=201 Created token=XXXXX Cleaning up file based variables 00:01 Job succeededOutput of checks
This bug happens on gitlab server omnibus 14.2.4-ee.0
Results of GitLab environment info
Expand for output related to GitLab environment info
/# gitlab-rake gitlab:env:info System information System: Proxy: no Current User: git Using RVM: no Ruby Version: 2.7.2p137 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.6 Redis Version: 6.0.14 Git Version: 2.32.0 Sidekiq Version:5.2.9 Go Version: unknown GitLab information Version: 14.2.4-ee Revision: 172062927c2 Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 12.7 URL: https://XXXXXXXXXXXXXXXXXX HTTP Clone URL: https://XXXXXXXXXXXXXXXXXX/some-group/some-project.git SSH Clone URL: git@XXXXXXXXXXXXXXXXXX:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: GitLab Shell Version: 13.19.1 Repository storage paths: - default: /var/opt/gitlab/git-data/repositories GitLab Shell path: /opt/gitlab/embedded/service/gitlab-shell Git: /opt/gitlab/embedded/bin/git
Results of GitLab application Check
Expand for output related to the GitLab application check
/# gitlab-rake gitlab:check SANITIZE=true Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 13.19.1 ? ... OK (13.19.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful
Checking GitLab Shell ... Finished
Checking Gitaly ...
Gitaly: ... default ... OK
Checking Gitaly ... Finished
Checking Sidekiq ...
Sidekiq: ... Running? ... yes Number of Sidekiq processes (cluster/worker) ... 1/1
Checking Sidekiq ... Finished
Checking Incoming Email ...
Incoming Email: ... Reply by email is disabled in config/gitlab.yml
Checking Incoming Email ... Finished
Checking LDAP ...
LDAP: ... Server: ldapmain not verifying SSL hostname of LDAPS server 'XXXXXXXXXXXXXXXXXXXXXXXXXX' LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 100 users of 100 limit. Server: ldapsecondary not verifying SSL hostname of LDAPS server 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) User output sanitized. Found 43 users of 100 limit.
Checking LDAP ... Finished
Checking GitLab App ...
Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... XXXXXXXXXXXX Redis version >= 5.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.31.0 ? ... yes (2.32.0) Git user has default SSH configuration? ... yes Active users: ... XXX Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... skipped (elasticsearch is disabled)
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished