Environment
- Gitlab.com
- Apex
Prerequisites
First I prepare deployed Apex and Apex which tests that. The Apex code are shown as below.
Code
CI in gitlab comes to move by putting .gitlab-ci.yml in the route of a repository of gitlab. The example is shown as below.
When you execute git push
, this process is carried out.
The summary of the process written in .gitlab-ci.yml is as follows.
in before_script section
- install force-dev-tool
- login production organization ( using access information written in
config/.orgs.json
). - remove directories exclude
classes/
,pages/
,staticresources/
,triggers/
andaura/
inforce-app/main/default/
directory ( this directory structure is the standard structure with using VSCode's Salesforce Extension Pack ). - make
force-app/main/default/package.xml
to deploy modules which are ApexClass, ApexComponent, ApexPage, ApexTrigger, StaticResource and AuraDefinitionBundle.
in test_deploy_production section
- run
force-dev-tool deploy
as test only mode.
in deploy_production section
- run
force-dev-tool deploy
as deploy to production environment.
config/.orgs.json
The example of config/.orgs.json
is shown as below.