Upload logs to a DCI job
Sometimes, it may happen that a DCI job is not able to retrieve a file to be saved in the DCI job's Files section.
Currently, there's a rescue section when uploading the logs that saves the file locally in case it's not possible to submit it by the time the DCI job is running. Same applies to dci-openshift-app-agent.
This utility allows users to upload any file to a DCI job that may have not been submitted previously in the job.
For this to work, you need to:
-
Have the following environment variables in your terminal:
-
Variables related to your remoteci credentials, i.e.
DCI_CLIENT_ID
,DCI_API_SECRET
andDCI_CS_URL
, which can be obtained from your remoteci credentials file in DCI. - Variables related to the DCI job, identified by
DCI_JOB_ID
variable. -
Variables related to the files to submit, which have to be placed in a directory pointed by a variable called
DCI_LOGS_FOLDER
-
Run properly the playbook.
Here's an example of execution. Imagine you want to upload the following files:
$ pwd
/tmp/upload-logs
# in our case, we've created a file with the env vars we need
$ ls
ansible.cfg env_vars.sh files upload-logs.yml
$ ls files/
example-upload-2.yml example-upload.txt
$ cat files/example-upload.txt
hello from custom playbook
$ cat files/example-upload-2.yml
---
msg: "hello from custom playbook"
...
To this DCI job, whose job ID is 99317fd3-526a-4fe2-b293-f8697c4c37d2.
The variables you need to export are:
$ cat env_vars.sh
DCI_CLIENT_ID='remoteci/xxx'
DCI_API_SECRET='yyy'
DCI_CS_URL='https://api.distributed-ci.io/'
export DCI_CLIENT_ID
export DCI_API_SECRET
export DCI_CS_URL
DCI_JOB_ID='99317fd3-526a-4fe2-b293-f8697c4c37d2'
DCI_LOGS_FOLDER='/tmp/upload-logs/files'
export DCI_JOB_ID
export DCI_LOGS_FOLDER
$ source env_vars.sh
Then, you're ready to launch the playbook, for example: $ ansible-playbook -v upload-logs.yml
In the DCI job commented before, you have these files uploaded: [example-upload-2.yml]https://www.distributed-ci.io/files/cebc4ddc-3f55-4d0a-b67f-c889a4a95939) and example-upload.txt