Hello,
I looked over at the api CircleCI API, and wanted to check in here how I could get these pieces of information
- The masked secrets pertaining to a context (as if I invited the context page)
- What contexts a repo is using (and in what job)
Hello,
I looked over at the api CircleCI API, and wanted to check in here how I could get these pieces of information
Hi @JeaneCA,
Regarding your first question, there is no public-facing REST API endpoint to get a list of masked secret values for a particular context. It is possible to get a list of the names of the variables in a specific context with the following endpoint:
https://circleci.com/docs/api/v2/#operation/listEnvironmentVariablesFromContext
If you would like to get a list of the unmasked values, you can rerun a job with ssh and use a command like env
to print them in plaintext. You could also add a step to echo the variables to a file and then upload that as an artifact (which can then be downloaded in the UI via our API).
For your second question, it is not directly possible to get a list of contexts used in a project. However you can get the contexts used in a specific job with the following endpoint:
You could then loop through the jobs in a project to get a list of contexts used overall.
Please let me know if you have any additional questions!
Gotcha. Thanks for clarifying what y’all have.
I feel like having a job to output secrets sounds hacky/unsecure. We like that the API can show us project secrets masked, we’d like to have a feature request that y’all also do the same for context API one day.
Best,
Jeane
@JeaneCA I agree that our API could be more versatile, and if you would like to submit a feature request you can do so on the following page:
Thanks!