diff --git a/awx/api/serializers.py b/awx/api/serializers.py index 4cd4353380..5f45d14937 100644 --- a/awx/api/serializers.py +++ b/awx/api/serializers.py @@ -1350,6 +1350,7 @@ class ProjectOptionsSerializer(BaseSerializer): 'scm_branch', 'scm_refspec', 'scm_clean', + 'scm_track_submodules', 'scm_delete_on_update', 'credential', 'timeout', @@ -1384,6 +1385,8 @@ class ProjectOptionsSerializer(BaseSerializer): errors['scm_branch'] = _('SCM branch cannot be used with archive projects.') if attrs.get('scm_refspec') and scm_type != 'git': errors['scm_refspec'] = _('SCM refspec can only be used with git projects.') + if attrs.get('scm_track_submodules') and scm_type != 'git': + errors['scm_track_submodules'] = _('SCM track_submodules can only be used with git projects.') if errors: raise serializers.ValidationError(errors) @@ -1510,7 +1513,7 @@ class ProjectSerializer(UnifiedJobTemplateSerializer, ProjectOptionsSerializer): ) if get_field_from_model_or_attrs('scm_type') == '': - for fd in ('scm_update_on_launch', 'scm_delete_on_update', 'scm_clean'): + for fd in ('scm_update_on_launch', 'scm_delete_on_update', 'scm_track_submodules', 'scm_clean'): if get_field_from_model_or_attrs(fd): raise serializers.ValidationError({fd: _('Update options must be set to false for manual projects.')}) return super(ProjectSerializer, self).validate(attrs) diff --git a/awx/main/migrations/0136_scm_track_submodules.py b/awx/main/migrations/0136_scm_track_submodules.py new file mode 100644 index 0000000000..b2977906ea --- /dev/null +++ b/awx/main/migrations/0136_scm_track_submodules.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.16 on 2021-04-13 19:21 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0135_schedule_sort_fallback_to_id'), + ] + + operations = [ + migrations.AddField( + model_name='project', + name='scm_track_submodules', + field=models.BooleanField(default=False, help_text='Track submodules latest commits on defined branch.'), + ), + migrations.AddField( + model_name='projectupdate', + name='scm_track_submodules', + field=models.BooleanField(default=False, help_text='Track submodules latest commits on defined branch.'), + ), + ] diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index b510a1b020..2125080bfb 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -115,6 +115,10 @@ class ProjectOptions(models.Model): default=False, help_text=_('Delete the project before syncing.'), ) + scm_track_submodules = models.BooleanField( + default=False, + help_text=_('Track submodules latest commits on defined branch.'), + ) credential = models.ForeignKey( 'Credential', related_name='%(class)ss', diff --git a/awx/main/tasks.py b/awx/main/tasks.py index fd01a6140e..f6474e41da 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -2044,6 +2044,7 @@ class RunProjectUpdate(BaseTask): 'scm_url': scm_url, 'scm_branch': scm_branch, 'scm_clean': project_update.scm_clean, + 'scm_track_submodules': project_update.scm_track_submodules, 'roles_enabled': galaxy_creds_are_defined and settings.AWX_ROLES_ENABLED, 'collections_enabled': galaxy_creds_are_defined and settings.AWX_COLLECTIONS_ENABLED, } diff --git a/awx/playbooks/project_update.yml b/awx/playbooks/project_update.yml index e00bed4249..092cfd0467 100644 --- a/awx/playbooks/project_update.yml +++ b/awx/playbooks/project_update.yml @@ -12,6 +12,7 @@ # scm_password: password (only for svn/insights) # scm_accept_hostkey: true/false (only for git, set automatically) # scm_refspec: a refspec to fetch in addition to obtaining version +# scm_track_submodules: true/false # roles_enabled: Value of the global setting to enable roles downloading # collections_enabled: Value of the global setting to enable collections downloading # awx_version: Current running version of the awx or tower as a string @@ -36,6 +37,7 @@ version: "{{scm_branch|quote}}" refspec: "{{scm_refspec|default(omit)}}" force: "{{scm_clean}}" + track_submodules: "{{scm_track_submodules|default(omit)}}" accept_hostkey: "{{scm_accept_hostkey|default(omit)}}" register: git_result diff --git a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx index 0ab2d6d31f..f47045aee3 100644 --- a/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx +++ b/awx/ui_next/src/components/PromptDetail/PromptProjectDetail.jsx @@ -18,6 +18,7 @@ function PromptProjectDetail({ i18n, resource }) { scm_branch, scm_clean, scm_delete_on_update, + scm_track_submodules, scm_refspec, scm_type, scm_update_on_launch, @@ -30,6 +31,7 @@ function PromptProjectDetail({ i18n, resource }) { if ( scm_clean || scm_delete_on_update || + scm_track_submodules || scm_update_on_launch || allow_override ) { @@ -39,6 +41,11 @@ function PromptProjectDetail({ i18n, resource }) { {scm_delete_on_update && ( {i18n._(t`Delete on Update`)} )} + {scm_track_submodules && ( + + {i18n._(t`Track submodules latest commit on branch`)} + + )} {scm_update_on_launch && ( {i18n._(t`Update Revision on Launch`)} )} diff --git a/awx/ui_next/src/components/PromptDetail/data.project.json b/awx/ui_next/src/components/PromptDetail/data.project.json index 24ed7ff1a6..371cc1d088 100644 --- a/awx/ui_next/src/components/PromptDetail/data.project.json +++ b/awx/ui_next/src/components/PromptDetail/data.project.json @@ -96,6 +96,7 @@ "scm_refspec":"refs/", "scm_clean":true, "scm_delete_on_update":true, + "scm_track_submodules":false, "credential":9, "timeout":0, "scm_revision":"", @@ -111,4 +112,4 @@ "last_update_failed":false, "last_updated":"2020-03-11T20:18:14Z", "default_environment": 1 -} \ No newline at end of file +} diff --git a/awx/ui_next/src/screens/Project/ProjectAdd/ProjectAdd.test.jsx b/awx/ui_next/src/screens/Project/ProjectAdd/ProjectAdd.test.jsx index 76bfd49256..2d7975e149 100644 --- a/awx/ui_next/src/screens/Project/ProjectAdd/ProjectAdd.test.jsx +++ b/awx/ui_next/src/screens/Project/ProjectAdd/ProjectAdd.test.jsx @@ -18,6 +18,7 @@ describe('', () => { scm_type: 'git', scm_url: 'https://foo.bar', scm_clean: true, + scm_track_submodules: false, credential: 100, local_path: '', organization: { id: 2, name: 'Bar' }, diff --git a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx index 355eb2e42e..0d33d9dfef 100644 --- a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx +++ b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.jsx @@ -36,6 +36,7 @@ function ProjectDetail({ project, i18n }) { scm_branch, scm_clean, scm_delete_on_update, + scm_track_submodules, scm_refspec, scm_type, scm_update_on_launch, @@ -58,6 +59,7 @@ function ProjectDetail({ project, i18n }) { if ( scm_clean || scm_delete_on_update || + scm_track_submodules || scm_update_on_launch || allow_override ) { @@ -67,6 +69,11 @@ function ProjectDetail({ project, i18n }) { {scm_delete_on_update && ( {i18n._(t`Delete on Update`)} )} + {scm_track_submodules && ( + + {i18n._(t`Track submodules latest commit on branch`)} + + )} {scm_update_on_launch && ( {i18n._(t`Update Revision on Launch`)} )} diff --git a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx index 6f65e6b7f7..34ef0d6beb 100644 --- a/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx +++ b/awx/ui_next/src/screens/Project/ProjectDetail/ProjectDetail.test.jsx @@ -70,6 +70,7 @@ describe('', () => { scm_refspec: 'refs/remotes/*', scm_clean: true, scm_delete_on_update: true, + scm_track_submodules: false, credential: 100, status: 'successful', organization: 10, @@ -141,6 +142,7 @@ describe('', () => { scm_type: '', scm_clean: false, scm_delete_on_update: false, + scm_track_submodules: false, scm_update_on_launch: false, allow_override: false, created: '', diff --git a/awx/ui_next/src/screens/Project/ProjectEdit/ProjectEdit.test.jsx b/awx/ui_next/src/screens/Project/ProjectEdit/ProjectEdit.test.jsx index 1a62a3f2f0..6e7b4b22f1 100644 --- a/awx/ui_next/src/screens/Project/ProjectEdit/ProjectEdit.test.jsx +++ b/awx/ui_next/src/screens/Project/ProjectEdit/ProjectEdit.test.jsx @@ -19,6 +19,7 @@ describe('', () => { scm_type: 'git', scm_url: 'https://foo.bar', scm_clean: true, + scm_track_submodules: false, credential: 100, local_path: 'bar', organization: 2, diff --git a/awx/ui_next/src/screens/Project/data.project.json b/awx/ui_next/src/screens/Project/data.project.json index 69ee22a34e..9f58e5243b 100644 --- a/awx/ui_next/src/screens/Project/data.project.json +++ b/awx/ui_next/src/screens/Project/data.project.json @@ -104,6 +104,7 @@ "scm_refspec": "", "scm_clean": false, "scm_delete_on_update": false, + "scm_track_submodules": false, "credential": null, "timeout": 0, "scm_revision": "f5de82382e756b87143f3511c7c6c006d941830d", @@ -119,4 +120,4 @@ "last_update_failed": false, "last_updated": "2019-09-30T18:06:34.713654Z", "execution_environment": 1 -} \ No newline at end of file +} diff --git a/awx/ui_next/src/screens/Project/shared/ProjectForm.jsx b/awx/ui_next/src/screens/Project/shared/ProjectForm.jsx index 9ce8aa555b..f880724469 100644 --- a/awx/ui_next/src/screens/Project/shared/ProjectForm.jsx +++ b/awx/ui_next/src/screens/Project/shared/ProjectForm.jsx @@ -84,6 +84,7 @@ function ProjectFormFields({ credential: '', scm_clean: false, scm_delete_on_update: false, + scm_track_submodules: false, scm_update_on_launch: false, allow_override: false, scm_update_cache_timeout: 0, @@ -308,6 +309,7 @@ function ProjectForm({ i18n, project, submitError, ...props }) { credential: '', scm_clean: false, scm_delete_on_update: false, + scm_track_submodules: false, scm_update_on_launch: false, allow_override: false, scm_update_cache_timeout: 0, @@ -365,6 +367,7 @@ function ProjectForm({ i18n, project, submitError, ...props }) { scm_branch: project.scm_branch || '', scm_clean: project.scm_clean || false, scm_delete_on_update: project.scm_delete_on_update || false, + scm_track_submodules: project.scm_track_submodules || false, scm_refspec: project.scm_refspec || '', scm_type: project.scm_type === '' diff --git a/awx/ui_next/src/screens/Project/shared/ProjectForm.test.jsx b/awx/ui_next/src/screens/Project/shared/ProjectForm.test.jsx index 33c528c45c..0a34bde6ea 100644 --- a/awx/ui_next/src/screens/Project/shared/ProjectForm.test.jsx +++ b/awx/ui_next/src/screens/Project/shared/ProjectForm.test.jsx @@ -17,6 +17,7 @@ describe('', () => { scm_type: 'git', scm_url: 'https://foo.bar', scm_clean: true, + scm_track_submodules: false, credential: 100, organization: 2, scm_update_on_launch: true, diff --git a/awx/ui_next/src/screens/Project/shared/ProjectSubForms/SharedFields.jsx b/awx/ui_next/src/screens/Project/shared/ProjectSubForms/SharedFields.jsx index 6fc0fb1c0e..8393f32fa4 100644 --- a/awx/ui_next/src/screens/Project/shared/ProjectSubForms/SharedFields.jsx +++ b/awx/ui_next/src/screens/Project/shared/ProjectSubForms/SharedFields.jsx @@ -84,6 +84,19 @@ export const ScmTypeOptions = withI18n()( of time required to complete an update.` )} /> +