Open Jean-Baptiste-Lasselle opened 3 years ago
even better, simpler example of pushed notifications from mongodb (perfect mongo) : https://dev.to/m10otb/real-time-notification-web-app-2ebn
Ok,n SO i'll o that one :
I will use exact same pattern, batch job and mongo db , to reactively update web ui for piplines execution state : it will be a sync, wtih a force sync button, Or... I don't know... actually no, it will be so much simpler to just limit API call to update execution state for each pipeline, or for a page of pipelines.... Yeah I just pull the pipeline states, I really don't care about seeing more than what I have on page, I don't want to conduct like large sets metrics calculations , it's always just about displaying the state of a few pipelines.
yes indeed : what i do ned to be extremely reactive, pushed and solid, etc... is the git repos list, the branch list as well
All in all :say I have a new Pipeline execution and it shows a new git branch , between two syncs :
pipeline executions state are going to be pushed, but with rate limit like every 3 seconds (slow), and the push updates the database iff there are differences between persisted state, and new state
Alright, So :
User
entity, is the userRepository
object in this example. K fine, let's roll with thisFinally , Dockerize everything, I wan in the end a docker-compse and a helmchart (tested on K3D) with :
./secret.json
later:
./secret.json
containing the circle ci api token , alsoconsider how to use the secrethub inside the K8S cluster, todobetter,and set the secrethub credential as K8S secretbeing able to persist to dataabse, shoudl be enough to implement all Endpoints in next Task :
Github API Client methods used by the batch and the Express Endpoints for pull :
For pull :
[ GET /backend/github/git-branches]
: returns git branches of a given repo, in a given org, speicified with JSON Payload, logs, and no database persistence (require Github Authentication)
[ GET /backend/circleci/pipeline-config]
: returns the YAML .circleci/config.yml
of a given repo, in a given org, ona given git branch, specified with JSON Payload, logs, and no database persistence. On client side, either :
modify the [ POST /backend/circleci/trigger-pipeline]
, so that every time a pipeline execution is triggered, the value of the parameters is persisted to mongo database, with pipeline execution GUID (then all triggered pipeline execution can be listed
add a new [ GET /backend/circleci/pipeline-executions]
returns the list of all pipeline executions, paginated with next page token , from a github org name , see https://circleci.com/docs/api/v2/#operation/listPipelines . pagination will be based on Circle CI Pagination :
add a new [ GET /backend/circleci/pipeline-executions-of]
returns the list of all pipeline executions of a given repo, paginated with next page token , from a github org name, and the repo name , see https://circleci.com/docs/api/v2/#operation/listPipelinesForProject . The data will be fetched from database and Circle CI API. pagination will be based on Circle CI Pagination :
first we retrieve all pipeline execution states from Circle CI, with the next page token, using https://circleci.com/docs/api/v2/#operation/listPipelinesForProject ,
and for each Pipeline GUID, it gets the parameters value passed when triggered, from mongodb database, to Pipeline GUID as primary key obviously
and for each Pipeline GUID, it gets the parameters value passed when triggered, from mongodb database, to Pipeline GUID as primary key obviously
add a new [ GET /backend/circleci/pipeline-execution-state]
which returns, from Pipeline GUID, the full detailed execution state of a given pipeline :
Ok, so all in all, here what is new,is that I want to remember the values of the passed parameters : can Jenkins tell you that?I am not sure.
Ok, So here I will need to experiment to websocket and push pattern :
Now, In this web ui ghallagher,I have a database with all pipeline parameters valeus for every Invocations :
Grafana loki
What I want, is that in the web app, the form to trigger the pipeline automatically adapts to the parameters, according the pipeline's configuration file :
https://circleci.com/docs/api/v2/#operation/getPipelineConfigById
[x] First, I will group all Routers that are about pipelines executions (listing them,triggering a pipeline execution) in one subfolder name
pipeline-executions
[ ] I need one more endpoint to be able to get all git repos "all projects":
git
branches for each repo I followNow,this is where I Willneed Github OAuth :
./src/server/lib/auth/permissions/pokus/github/index.ts
line 112Now retrieving all those informations from both Github and Circle CI API v1, will be a btach job, that will need the Github API Token obtained from the Github OAuth:
Ok so the Batch job will take a parameter : the Github API scoped Token. With this token, the batch will get the user name , and use it to persist job result to database :