-
Notifications
You must be signed in to change notification settings - Fork 554
feat:Poll Images from ECR Container Repository Plugin #3971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
c4f779a
trigger Ci Cron
Ashish-devtron 3b1ffbc
changes for adding job in devtron apps
iamayushm 52c9fbd
port-fix
iamayushm 093a62c
main merge
Ashish-devtron 90488cc
setting flag in pipeline db
iamayushm 89e3756
fix ecr repo save condition
iamayushm e702b8c
fix corrupt data save
iamayushm 51bd92b
adding build context git material id
iamayushm 3955d8a
pg no rows fix
iamayushm 4b5a07a
plugin support
Shivam-nagar23 b4715c7
plugin support
Shivam-nagar23 027e14c
main-merge
Shivam-nagar23 91a2301
Merge remote-tracking branch 'origin/cron-trigger' into plugin-poll-s…
Shivam-nagar23 4ec2bf7
trigger ci for JOB_Ci
Ashish-devtron 65987f6
use const
Ashish-devtron 5500856
remove only git material from ciMaterial
Ashish-devtron 1641402
Merge branch 'main' into job-devtron-apps
iamayushm 3f10998
Merge remote-tracking branch 'origin/cron-trigger' into cr-plugin-test
iamayushm affdcb0
Logging ci complete event
Shivam-nagar23 5f776dc
vendor-update
Shivam-nagar23 e50001d
icon for plugin
Shivam-nagar23 3196231
Merge branch 'cron-trigger' into job-devtron-apps
iamayushm 6f1a638
get plugin Id from name
Ashish-devtron 937dd39
revert connection.go port
Ashish-devtron 4450ec4
sorting only latest image
Shivam-nagar23 77dccf4
Merge branch 'job-devtron-apps' into cr-plugin-test
iamayushm 6566e3b
Merge branch 'cron-trigger' into cr-plugin-test
iamayushm 898e850
logs and script addition
Shivam-nagar23 8157055
Merge remote-tracking branch 'origin/cr-plugin-test' into plugin-poll…
Shivam-nagar23 d67f4a9
script number change
Shivam-nagar23 f5b3754
update envDefault
Ashish-devtron d35a960
Merge branch 'main' into plugin-poll-support
Shivam-nagar23 5045b11
docker parameters
iamayushm 71244b4
docker repo create enable
iamayushm 0ef3cba
Merge remote-tracking branch 'origin/cr-plugin-test' into plugin-poll…
Shivam-nagar23 4cc8917
update envDefault
Ashish-devtron 6d697ad
Merge branch 'plugin-poll-support' of github.com:devtron-labs/devtron…
Ashish-devtron 0e01681
sent last fetch artifact time
Ashish-devtron db10a7b
change SourceControllerCronTime env
Ashish-devtron 14a8b60
change type for cron
Ashish-devtron f1594f2
change query
Ashish-devtron 8bf9892
image update
Shivam-nagar23 542df85
review comments
Shivam-nagar23 184a1e5
review comments
Shivam-nagar23 9f3d2fc
review comments
Shivam-nagar23 539d824
image plugin change
Shivam-nagar23 f957c9d
update down script
Shivam-nagar23 027ff85
pipeline type flag
iamayushm 338f2ba
flag in app group api
iamayushm 6169e24
Merge branch 'main' into plugin-poll-support
Shivam-nagar23 294b535
script update
Shivam-nagar23 ce303aa
comments
Shivam-nagar23 84ffe61
script change
Shivam-nagar23 bd8a516
app clone handle
iamayushm c525146
fixed ci pod request (#3980)
kartik-579 faac3e1
fixed pipelineOverride id being sent instead of pipelineId (#3984)
kartik-579 a47fe17
chore: added CODEOWNERS (#3966)
Shubham9t9 082bac2
Merge branch 'main' into plugin-poll-support
Shivam-nagar23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| package cron | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "github.com/caarlos0/env" | ||
| repository2 "github.com/devtron-labs/devtron/internal/sql/repository" | ||
| "github.com/devtron-labs/devtron/pkg/bean" | ||
| "github.com/devtron-labs/devtron/pkg/pipeline" | ||
| bean2 "github.com/devtron-labs/devtron/pkg/pipeline/bean" | ||
| "github.com/devtron-labs/devtron/pkg/pipeline/repository" | ||
| repository3 "github.com/devtron-labs/devtron/pkg/plugin/repository" | ||
| "github.com/robfig/cron/v3" | ||
| "go.uber.org/zap" | ||
| ) | ||
|
|
||
| type CiTriggerCron interface { | ||
| TriggerCiCron() | ||
| } | ||
|
|
||
| type CiTriggerCronImpl struct { | ||
| logger *zap.SugaredLogger | ||
| cron *cron.Cron | ||
| cfg *CiTriggerCronConfig | ||
| pipelineStageRepository repository.PipelineStageRepository | ||
| ciHandler pipeline.CiHandler | ||
| ciArtifactRepository repository2.CiArtifactRepository | ||
| globalPluginRepository repository3.GlobalPluginRepository | ||
| } | ||
|
|
||
| func NewCiTriggerCronImpl(logger *zap.SugaredLogger, cfg *CiTriggerCronConfig, pipelineStageRepository repository.PipelineStageRepository, | ||
| ciHandler pipeline.CiHandler, ciArtifactRepository repository2.CiArtifactRepository, globalPluginRepository repository3.GlobalPluginRepository) *CiTriggerCronImpl { | ||
| cron := cron.New( | ||
| cron.WithChain()) | ||
| cron.Start() | ||
| impl := &CiTriggerCronImpl{ | ||
| logger: logger, | ||
| cron: cron, | ||
| pipelineStageRepository: pipelineStageRepository, | ||
| ciHandler: ciHandler, | ||
| cfg: cfg, | ||
| ciArtifactRepository: ciArtifactRepository, | ||
| globalPluginRepository: globalPluginRepository, | ||
| } | ||
|
|
||
| _, err := cron.AddFunc(fmt.Sprintf("@every %dm", cfg.SourceControllerCronTime), impl.TriggerCiCron) | ||
| if err != nil { | ||
| logger.Errorw("error while configure cron job for ci workflow status update", "err", err) | ||
| return impl | ||
| } | ||
| return impl | ||
| } | ||
|
|
||
| type CiTriggerCronConfig struct { | ||
| SourceControllerCronTime int `env:"CI_TRIGGER_CRON_TIME" envDefault:"2"` | ||
| PluginName string `env:"PLUGIN_NAME" envDefault:"Pull images from container repository"` | ||
| } | ||
|
|
||
| func GetCiTriggerCronConfig() (*CiTriggerCronConfig, error) { | ||
| cfg := &CiTriggerCronConfig{} | ||
| err := env.Parse(cfg) | ||
| if err != nil { | ||
| fmt.Println("failed to parse ci trigger cron config: " + err.Error()) | ||
| return nil, err | ||
| } | ||
| return cfg, nil | ||
| } | ||
|
|
||
| // UpdateCiWorkflowStatusFailedCron this function will execute periodically | ||
| func (impl *CiTriggerCronImpl) TriggerCiCron() { | ||
| plugin, err := impl.globalPluginRepository.GetPluginByName(impl.cfg.PluginName) | ||
| if err != nil || len(plugin) == 0 { | ||
| return | ||
| } | ||
|
|
||
| ciPipelineIds, err := impl.pipelineStageRepository.GetAllCiPipelineIdsByPluginIdAndStageType(plugin[0].Id, string(repository.PIPELINE_STAGE_TYPE_PRE_CI)) | ||
| if err != nil { | ||
| return | ||
| } | ||
| for _, ciPipelineId := range ciPipelineIds { | ||
| var ciPipelineMaterials []bean.CiPipelineMaterial | ||
| ciTriggerRequest := bean.CiTriggerRequest{ | ||
| PipelineId: ciPipelineId, | ||
| CiPipelineMaterial: ciPipelineMaterials, | ||
| TriggeredBy: 1, | ||
| InvalidateCache: false, | ||
| PipelineType: bean2.CI_JOB, | ||
| } | ||
| _, err = impl.ciHandler.HandleCIManual(ciTriggerRequest) | ||
| if err != nil { | ||
| return | ||
| } | ||
| } | ||
| return | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put comments