This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch feat-dora-config in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 5436b682b95c5a36789772fd1ba72d9dd617c7f6 Author: mintsweet <0x1304...@gmail.com> AuthorDate: Wed Sep 18 09:17:03 2024 +1200 feat: improve the bitbucket transformation cicd configuration --- .../plugins/components/scope-config-form/index.tsx | 2 + .../register/bitbucket/assets/workflow-run-1.jpeg | Bin 0 -> 71873 bytes .../register/bitbucket/assets/workflow-run-2.jpeg | Bin 0 -> 52643 bytes .../src/plugins/register/bitbucket/config.tsx | 2 - .../plugins/register/bitbucket/transformation.tsx | 103 +++++++++++++------- .../plugins/register/bitbucket/workflow-run.tsx | 104 +++++++++++++++++++++ 6 files changed, 174 insertions(+), 37 deletions(-) diff --git a/config-ui/src/plugins/components/scope-config-form/index.tsx b/config-ui/src/plugins/components/scope-config-form/index.tsx index b3341d1bd..6a14f9ed8 100644 --- a/config-ui/src/plugins/components/scope-config-form/index.tsx +++ b/config-ui/src/plugins/components/scope-config-form/index.tsx @@ -219,6 +219,8 @@ export const ScopeConfigForm = ({ {plugin === 'bitbucket' && ( <BitbucketTransformation + plugin="bitbucket" + connectionId={connectionId} entities={entities} transformation={transformation} setTransformation={setTransformation} diff --git a/config-ui/src/plugins/register/bitbucket/assets/workflow-run-1.jpeg b/config-ui/src/plugins/register/bitbucket/assets/workflow-run-1.jpeg new file mode 100644 index 000000000..4d8edae8e Binary files /dev/null and b/config-ui/src/plugins/register/bitbucket/assets/workflow-run-1.jpeg differ diff --git a/config-ui/src/plugins/register/bitbucket/assets/workflow-run-2.jpeg b/config-ui/src/plugins/register/bitbucket/assets/workflow-run-2.jpeg new file mode 100644 index 000000000..e561e1305 Binary files /dev/null and b/config-ui/src/plugins/register/bitbucket/assets/workflow-run-2.jpeg differ diff --git a/config-ui/src/plugins/register/bitbucket/config.tsx b/config-ui/src/plugins/register/bitbucket/config.tsx index 6d7cc6237..9f279e27d 100644 --- a/config-ui/src/plugins/register/bitbucket/config.tsx +++ b/config-ui/src/plugins/register/bitbucket/config.tsx @@ -69,8 +69,6 @@ export const BitbucketConfig: IPluginConfig = { issueStatusInProgress: '', issueStatusDone: 'closed', issueStatusOther: 'on hold,wontfix,duplicate,invalid', - deploymentPattern: '', - productionPattern: '', refdiff: { tagsLimit: 10, tagsPattern: '/v\\d+\\.\\d+(\\.\\d+(-rc)*\\d*)*$/', diff --git a/config-ui/src/plugins/register/bitbucket/transformation.tsx b/config-ui/src/plugins/register/bitbucket/transformation.tsx index 40b2c5e38..5f1fe348a 100644 --- a/config-ui/src/plugins/register/bitbucket/transformation.tsx +++ b/config-ui/src/plugins/register/bitbucket/transformation.tsx @@ -20,12 +20,16 @@ import { useMemo, useState, useEffect } from 'react'; import { CaretRightOutlined } from '@ant-design/icons'; import { theme, Collapse, Tag, Form, Input, Checkbox, Select } from 'antd'; -import { ExternalLink, HelpTooltip } from '@/components'; +import { ShowMore, ExternalLink, HelpTooltip } from '@/components'; +import { CheckMatchedItems } from '@/plugins'; import { DOC_URL } from '@/release'; import ExampleJpg from './assets/bitbucket-example.jpg'; +import { WorkflowRun } from './workflow-run'; interface Props { + plugin: string; + connectionId: ID; entities: string[]; transformation: any; setTransformation: React.Dispatch<React.SetStateAction<any>>; @@ -33,7 +37,13 @@ interface Props { const ALL_STATES = ['new', 'open', 'resolved', 'closed', 'on hold', 'wontfix', 'duplicate', 'invalid']; -export const BitbucketTransformation = ({ entities, transformation, setTransformation }: Props) => { +export const BitbucketTransformation = ({ + plugin, + connectionId, + entities, + transformation, + setTransformation, +}: Props) => { const [useCustom, setUseCustom] = useState(false); useEffect(() => { @@ -58,6 +68,12 @@ export const BitbucketTransformation = ({ entities, transformation, setTransform const checked = (e.target as HTMLInputElement).checked; if (!checked) { + setTransformation({ + ...transformation, + deploymentPattern: undefined, + productionPattern: undefined, + }); + } else { setTransformation({ ...transformation, deploymentPattern: '', @@ -85,6 +101,8 @@ export const BitbucketTransformation = ({ entities, transformation, setTransform style={{ background: token.colorBgContainer }} size="large" items={renderCollapseItems({ + plugin, + connectionId, entities, panelStyle, options, @@ -98,6 +116,8 @@ export const BitbucketTransformation = ({ entities, transformation, setTransform }; const renderCollapseItems = ({ + plugin, + connectionId, entities, panelStyle, options, @@ -106,6 +126,8 @@ const renderCollapseItems = ({ useCustom, onChangeUseCustom, }: { + plugin: string; + connectionId: ID; entities: string[]; panelStyle: React.CSSProperties; options: Array<{ label: string; value: string }>; @@ -204,39 +226,50 @@ const renderCollapseItems = ({ <Checkbox checked={useCustom} onChange={onChangeUseCustom}> Convert a Bitbucket Pipeline to a DevLake Deployment when its branch/tag name </Checkbox> - <div style={{ margin: '8px 0', paddingLeft: 28 }}> - <span>matches</span> - <Input - style={{ width: 200, margin: '0 8px' }} - placeholder="(deploy|push-image)" - value={transformation.deploymentPattern ?? ''} - onChange={(e) => - onChangeTransformation({ - ...transformation, - deploymentPattern: e.target.value, - productionPattern: !e.target.value ? '' : transformation.productionPattern, - }) - } - /> - <span>.</span> - <HelpTooltip content="View your Bitbucket Pipelines: https://support.atlassian.com/bitbucket-cloud/docs/view-your-pipeline/" /> - </div> - <div style={{ margin: '8px 0', paddingLeft: 28 }}> - <span>If the name also matches</span> - <Input - style={{ width: 200, margin: '0 8px' }} - placeholder="prod(.*)" - value={transformation.productionPattern ?? ''} - onChange={(e) => - onChangeTransformation({ - ...transformation, - productionPattern: e.target.value, - }) - } - /> - <span>, this Deployment is a ‘Production Deployment’</span> - <HelpTooltip content="If you leave this field empty, all Deployments will be tagged as in the Production environment. " /> - </div> + {useCustom && ( + <div style={{ paddingLeft: 28 }}> + <ShowMore + text={<p>Select this option only if you are not enabling Bitbucket deployments.</p>} + btnText="See how to configure" + > + <WorkflowRun /> + </ShowMore> + <div style={{ margin: '8px 0' }}> + <span>Its branch or one of its steps matches</span> + <Input + style={{ width: 200, margin: '0 8px' }} + placeholder="(?i)(deploy|push-image)" + value={transformation.deploymentPattern ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + deploymentPattern: e.target.value, + productionPattern: !e.target.value ? '' : transformation.productionPattern, + }) + } + /> + <span>.</span> + <HelpTooltip content="View your Bitbucket Pipelines: https://support.atlassian.com/bitbucket-cloud/docs/view-your-pipeline/" /> + </div> + <div style={{ margin: '8px 0', paddingLeft: 28 }}> + <span>If the branch or the step also matches</span> + <Input + style={{ width: 200, margin: '0 8px' }} + placeholder="(?i)(prod|release)" + value={transformation.productionPattern ?? ''} + onChange={(e) => + onChangeTransformation({ + ...transformation, + productionPattern: e.target.value, + }) + } + /> + <span>, this deployment will be regarded as a ‘Production Deployment’.</span> + <HelpTooltip content="If you leave this field empty, all Deployments will be tagged as in the Production environment. " /> + </div> + <CheckMatchedItems plugin={plugin} connectionId={connectionId} transformation={transformation} /> + </div> + )} </> ), }, diff --git a/config-ui/src/plugins/register/bitbucket/workflow-run.tsx b/config-ui/src/plugins/register/bitbucket/workflow-run.tsx new file mode 100644 index 000000000..84ae27edd --- /dev/null +++ b/config-ui/src/plugins/register/bitbucket/workflow-run.tsx @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import { Flex, Input } from 'antd'; +import styled from 'styled-components'; + +import { ExternalLink } from '@/components'; + +import Picture1 from './assets/workflow-run-1.jpeg'; +import Picture2 from './assets/workflow-run-2.jpeg'; + +const Wrapper = styled.div` + padding: 8px 16px; + width: 100%; + font-size: 12px; + background-color: #fff; + box-sizing: border-box; + overflow: hidden; + + li { + margin-bottom: 20px; + + &:last-child { + margin-bottom: 0; + } + } + + span.blue { + color: #7497f7; + } + + span.yellow { + color: #f4be55; + } + + span.red { + color: #ff8b8b; + } +`; + +export const WorkflowRun = () => { + return ( + <Wrapper> + <h5> + Example - Convert Bitbucket pipelines that have executed the step ‘Deploy-to-prod’ to production deployments + </h5> + <ol> + <li>Go to your Bitbucket Pipelines page (as shown in the first picture). </li> + <li> + Locate a successful pipeline that have executed the step ‘Deploy-to-prod’, you will see all steps executed in + this pipeline (as shown in the second picture). + <Flex> + <img src={Picture1} width="100%" alt="" /> + <img src={Picture2} width="100%" alt="" /> + </Flex> + </li> + <li> + <div> + In the first input field, enter the following regex to identify this pipeline as a deployment (as + highlighted in the <span className="yellow">yellow</span> rectangle). + </div> + <div style={{ marginTop: 10 }}> + Its branch or one of its steps matches + <Input style={{ width: 240 }} size="small" disabled value="(?i)Deploy-to.*" /> + </div> + </li> + <li> + <div> + In the second input field, enter the following regex to identify the production deployments (highlighted in + the <span className="red">red</span> rectangle). If left empty, all pipelines containing the job in the{' '} + <span className="yellow">yellow</span> rectangle will be regarded as Production Deployments. + </div> + <div style={{ marginTop: 10 }}> + If the branch or the step also matches{' '} + <Input style={{ width: 100 }} size="small" disabled value="(?i)prod" />, this deployment will be regarded as + a ‘Production Deployment’ + </div> + </li> + </ol> + <div> + For more information, please refer to{' '} + <ExternalLink link="https://devlake.apache.org/docs/Configuration/BitBucket/#cicd"> + this documentation + </ExternalLink> + . + </div> + </Wrapper> + ); +};