Uploading artifacts for successful job
00:00
Uploading artifacts...
WARNING: sitespeed-results/: no matching files
ERROR: No files to upload
Uploading artifacts...
WARNING: browser-performance.json: no matching files
ERROR: No files to upload
Cleaning up project directory and file based variables
00:01
Job succeeded
gitlab-ci.yaml example :
include:
template: Verify/Browser-Performance.gitlab-ci.yml
browser_performance:
variables:
URL: https://example.com
DEGRADATION_THRESHOLD: 5
This error usually happens when there are no matching files found. Either move the files to the main directory, or specify the correct path to the files and folders. No matter where your script ends, gilab runner always searches for these files in the main/root directory of the project.
create a new folder inside $BITBUCKET_CLONE_DIR then copy your desired artifacts in that new folder?
After that, use the new folder as your artifacts.
See sample step below:
- step:
name: XXXX
image:
name: YYYY
username: $xxxy
password: $yyyy
script:
- mvn clean install --file $BITBUCKET_CLONE_DIR/xxxx/pom.xml
- mkdir –p $BITBUCKET_CLONE_DIR/dist
- cp -R xxx/target/* $BITBUCKET_CLONE_DIR/dist
- ls -lah $BITBUCKET_CLONE_DIR/dist
artifacts:
- dist/**
I hope this works
Check the path you have provided in the artifacts section:
artifacts:
paths:
- $CI_PROJECT_DIR
expire_in: 1 week
If you are choosing files only with some specific extensions like below, then GitLab Runner will not be able to find files with any other extensions:
artifacts:
paths:
- $CI_PROJECT_DIR/*.xlsx
expire_in: 1 week
So be careful with what are you mentioning in the "paths"
Related
i am trying the gitlab default secret detection option.
here is Gitlab CI file i am trying
include:
- template: Security/Secret-Detection.gitlab-ci.yml
stages:
- test
test:
stage: test
artifacts:
reports:
secret_detection: gl-secret-detection-report.json
script:
- pwd
- ls
- cat gl-secret-detection-report.json
i am not getting the file as artifacts.
error i am getting is :
cat: can't open 'gl-secret-detection-report.json': No such file or directory
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
however in default stage of Gitlab it is creating the file
Uploading artifacts for successful job
00:03
Uploading artifacts...
gl-secret-detection-report.json: found 1 matching files and directories
Uploading artifacts as "secret_detection" to coordinator... ok id=1asdfas239 responseStatus=201 Created token=jT28Z-ot
Cleaning up file based variables
00:00
Job succeeded
so secret_detection stage is working which is default using template.
i have a template that i don't want to be modified as follows:
build:
script:
- ...
artifacts:
name: $BINFILE
paths: [$ARTIFACTS_PATH]
and gitlab-ci.yaml that includes that template and the following vars
BINFILE: demo-bin-files
ARTIFACTS_PATH: "Build"
the artifacts NAME is substituted correctly by the var BINFILE but the var ARTIFACTS_PATH is not and throws an error while i start the job
Uploading artifacts...
WARNING: --artifact-format: no matching files
ERROR: No files to upload
What i want here is that user pass only the paths that he want to upload as artifacts.
Can i do this or Gitlab doesn't support that ? thanks
You can't
but you can achieve this using shell script.
Set the artifacts: path to a temp folder and in the last step of your script: or after_script: section, copy all the content that you generate dynamically to the temp folder
it will solve your problem until Gitlab add this feature
I've had a similar issue and there's a simple fix - use the template as ana actual template.
template.yml (note the dot in the job name denoting it as a template)
.build:
script:
- ...
.gitlab-ci.yml
build:
extends: .build
artifacts:
name: demo-bin-files
paths:
- Build
You can even define common artifact settings in the template like so:
template.yml
.build:
script:
- ...
artifacts:
when: always
expire_in: 6 hours
and .gitlab-ci.yml remains the same.
I have problems with GitLab not uploading the artifacts generated by codeception when a test fails. It only uploads the .gitignore in the _output folder.
This is the relevant part from my .gitlab-ci.yml:
- ./src/Vendor/codeception/codeception/codecept run acceptance || true
- ls -a tests/_output
artifacts:
paths:
- "tests/_output"
expire_in: 20 days
when: always
Interesting is, that I can browse the artifacts (in this case only the .gitignore-file) before the job even finished. The logs of my runner prove, that the artifacts do indeed exist in the directory tests/_output (shorted):
$ ls -a tests/_output
.
..
.gitignore
commentsCest.answerCommentTest.fail.html
commentsCest.answerCommentTest.fail.png
commentsCest.normalCommentTest.fail.html
commentsCest.normalCommentTest.fail.png
failed
Uploading artifacts...
tests/_output: found 2 matching files
Uploading artifacts to coordinator... ok id=123456789 responseStatus=201 Created token=abcdefghij
Job succeeded
What am I doing wrong?
I figured out a workaround:
The gitlab-runner only uploads files properly inside the project directory.
To get the artifacts, copy all files to ${CI_PROJECT_DIR}:
codeception_tests:
stage: <your stage-name>
image: <your image>
script:
- ...
after_script:
- mkdir ${CI_PROJECT_DIR}/artifacts
- mkdir ${CI_PROJECT_DIR}/artifacts/codecept
- cp tests/_output ${CI_PROJECT_DIR}/artifacts/codecept -R
artifacts:
paths:
- ${CI_PROJECT_DIR}/artifacts/
expire_in: 5 days
when: always
i have the following .gitlab.yaml file
stages:
- build
- test
compile:
stage:build
script:
- stuff_happening
test_1:
stage: test
script:
- do_something_1
artifacts:
when: on_failure
name: "$CI_COMMIT_REF_NAME"
paths:
- /root/dir
When test_1 is executed , it creates a folder dir inside root
I want to add it to artifacts but , i get an error saying:
no matching files. If I add - ls root in the job , I can see the folder.
There is an open question in support forum, but still no response there.
Can anyone help? Thanks
The issue here is that you are trying to upload files that are outside of the project's scope.
From the official documentation on artifacts:
You can only use paths that are within the project workspace.
The reason is obvious; if a git runner were allowed to upload anything outside its workspace, it would cause a serious security issues.
However, if you really wanted to upload anything outside the runner's workspace, you might want to try copying the files outside into the project's root folder, and uploading it from there.
The git runners are usually registered as user:group git-runner:git-runner and so it will likely require sudo privilege if you wanted it to copy files from /root.
According to https://docs.gitlab.com/ee/ci/yaml/README.html#artifacts
You can try adding an additional slash after your path.
paths:
- /root/dir/
Examples from the link above:
Send all files in binaries and .config:
artifacts:
paths:
- binaries/
- .config
I have a directory which is generated during a build and it should not be deleted in the next builds. I tried to keep the directory using cache in .gitlab-ci.yml:
cache:
key: "$CI_BUILD_REF_NAME"
untracked: true
paths:
- target_directory/
build-runner1:
stage: build
script:
- ./build-platform.sh target_directory
In the first build a cache.zip is generated but for the next builds the target_directory is deleted and the cache.zip is extracted which takes a very long time. Here is a log of the the second build:
Running with gitlab-ci-multi-runner 1.11.
on Runner1
Using Shell executor...
Running on Runner1...
Fetching changes...
Removing target_directory/
HEAD is now at xxxxx Update .gitlab-ci.yml
From xxxx
Checking out xxx as master...
Skipping Git submodules setup
Checking cache for master...
Successfully extracted cache
Is there a way that gitlab runner not remove the directory in the first place?
What you need is to use a job artifacts:
Artifacts is a list of files and directories which are attached to a
job after it completes successfully.
.gitlab-ci.yml file:
your job:
before_script:
- do something
script:
- do another thing
- do something to generate your zip file (example: myFiles.zip)
artifacts:
paths:
- myFiles.zip
After a job finishes, if you visit the job's specific page, you can see that there is a button for downloading the artifacts archive.
Note
If you need to pass artifacts between different jobs, you need to use dependencies.
Gitlab has a good documentation about that if you really have this need http://docs.gitlab.com/ce/ci/yaml/README.html#dependencies