You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2023/02/22 02:03:18 UTC

[incubator-devlake] branch main updated: feat: update cicd tips for bitbucket (#4476)

This is an automated email from the ASF dual-hosted git repository.

warren pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new a0dccf71c feat: update cicd tips for bitbucket (#4476)
a0dccf71c is described below

commit a0dccf71caef48180de4ae27d4014d5c220fefe4
Author: Likyh <ya...@meri.co>
AuthorDate: Wed Feb 22 10:03:13 2023 +0800

    feat: update cicd tips for bitbucket (#4476)
---
 backend/plugins/bitbucket/bitbucket.go             |   3 +-
 .../plugins/register/bitbucket/transformation.tsx  | 124 ++++++++++-----------
 2 files changed, 59 insertions(+), 68 deletions(-)

diff --git a/backend/plugins/bitbucket/bitbucket.go b/backend/plugins/bitbucket/bitbucket.go
index fb0f7fdb5..91ee34941 100644
--- a/backend/plugins/bitbucket/bitbucket.go
+++ b/backend/plugins/bitbucket/bitbucket.go
@@ -33,8 +33,7 @@ func main() {
 	fullName := cmd.Flags().StringP("fullName", "n", "", "bitbucket id: owner/repo")
 	createdDateAfter := cmd.Flags().StringP("createdDateAfter", "a", "", "collect data that are created after specified time, ie 2006-05-06T07:08:09Z")
 	_ = cmd.MarkFlagRequired("connectionId")
-	_ = cmd.MarkFlagRequired("owner")
-	_ = cmd.MarkFlagRequired("repo")
+	_ = cmd.MarkFlagRequired("fullName")
 
 	cmd.Run = func(cmd *cobra.Command, args []string) {
 		runner.DirectRun(cmd, args, PluginEntry, map[string]interface{}{
diff --git a/config-ui/src/plugins/register/bitbucket/transformation.tsx b/config-ui/src/plugins/register/bitbucket/transformation.tsx
index 3a28b3bf2..20bac6b3e 100644
--- a/config-ui/src/plugins/register/bitbucket/transformation.tsx
+++ b/config-ui/src/plugins/register/bitbucket/transformation.tsx
@@ -20,15 +20,12 @@ import React, {useMemo, useState} from 'react';
 import {
   FormGroup,
   InputGroup,
-  TextArea,
   Tag,
-  RadioGroup,
   Radio,
   Icon,
   Collapse,
   Intent,
-  Colors,
-  TagInput,
+  Checkbox,
 } from '@blueprintjs/core';
 
 import { ExternalLink, HelpTooltip, Divider, MultiSelector } from '@/components';
@@ -43,7 +40,7 @@ interface Props {
 const ALL_STATES = ['new', 'open', 'resolved', 'closed', 'on hold', 'wontfix', 'duplicate', 'invalid'];
 
 export const BitbucketTransformation = ({ transformation, setTransformation }: Props) => {
-  const [enableCICD, setEnableCICD] = useState(1);
+  const [enableCICD, setEnableCICD] = useState(false);
   const [openAdditionalSettings, setOpenAdditionalSettings] = useState(false);
   const selectedStates = useMemo(() => [
     ...transformation.issueStatusTodo ? transformation.issueStatusTodo.split(',') : [],
@@ -52,8 +49,8 @@ export const BitbucketTransformation = ({ transformation, setTransformation }: P
     ...transformation.issueStatusOther ? transformation.issueStatusOther.split(',') : [],
   ], [transformation]);
 
-  const handleChangeCICDEnable = (e: number) => {
-    if (e === 0) {
+  const handleChangeCICDEnable = (b: boolean) => {
+    if (b) {
       setTransformation({
         ...transformation,
         deploymentPattern: undefined,
@@ -66,7 +63,7 @@ export const BitbucketTransformation = ({ transformation, setTransformation }: P
         productionPattern: '',
       });
     }
-    setEnableCICD(e);
+    setEnableCICD(b);
   };
 
   const handleChangeAdditionalSettingsOpen = () => {
@@ -157,66 +154,61 @@ export const BitbucketTransformation = ({ transformation, setTransformation }: P
             DORA
           </Tag>
         </h3>
-        <p>Tell DevLake what CI jobs are Deployments.</p>
-        <RadioGroup
-          selectedValue={enableCICD}
-          onChange={(e) => handleChangeCICDEnable(+(e.target as HTMLInputElement).value)}
-        >
-          <Radio label="Detect Deployment from Builds in BitBucket" value={1} />
-          {enableCICD === 1 && (
-            <>
-              <p>
-                Not sure what a Bitbucket Action is?{' '}
-                <ExternalLink link="https://docs.github.com/en/actions/using-jobs/using-jobs-in-a-workflow">
-                  See it here
-                </ExternalLink>
-              </p>
-              <div className="radio">
-                <FormGroup
-                  inline
-                  label={
-                    <>
-                      <span>Deployment</span>
-                      <HelpTooltip content="A BitBucket build with a name that matches the RegEx will be considered as a deployment in DevLake." />
-                    </>
+        <p>
+          DevLake uses BitBucket{' '}
+          <ExternalLink link="https://support.atlassian.com/bitbucket-cloud/docs/set-up-and-monitor-deployments/">deployments</ExternalLink>
+          {' '}as DevLake deployments. If you are NOT using BitBucket deployments, DevLake provides the option to detect deployments from BitBucket pipeline steps.{' '}
+          <ExternalLink link="https://devlake.apache.org/docs/Configuration/BitBucket#step-3---adding-transformation-rules-optional">Learn more</ExternalLink>
+        </p>
+        <Checkbox label="Detect Deployments from Pipeline steps in BitBucket" checked={enableCICD}
+                  onChange={(e) => handleChangeCICDEnable((e.target as HTMLInputElement).checked)}
+        />
+        {enableCICD && (
+          <>
+            <div className="radio">
+              <FormGroup
+                inline
+                label={
+                  <>
+                    <span>Deployment</span>
+                    <HelpTooltip content="A BitBucket build with a name that matches the RegEx will be considered as a deployment in DevLake." />
+                  </>
+                }
+              >
+                <InputGroup
+                  placeholder="(?i)deploy"
+                  value={transformation.deploymentPattern}
+                  onChange={(e) =>
+                    setTransformation({
+                      ...transformation,
+                      deploymentPattern: e.target.value,
+                    })
                   }
-                >
-                  <InputGroup
-                    placeholder="(?i)deploy"
-                    value={transformation.deploymentPattern}
-                    onChange={(e) =>
-                      setTransformation({
-                        ...transformation,
-                        deploymentPattern: e.target.value,
-                      })
-                    }
-                  />
-                </FormGroup>
-                <FormGroup
-                  inline
-                  label={
-                    <>
-                      <span>Production</span>
-                      <HelpTooltip content="DevLake is only concerned with deployments in production environment when calculating DORA metrics. A BitBucket build with a name that matches the given RegEx will be considered as a job in the Production environment. If you leave this field empty, all data will be tagged as in the Production environment. " />
-                    </>
+                />
+              </FormGroup>
+              <FormGroup
+                inline
+                label={
+                  <>
+                    <span>Production Environment</span>
+                    <HelpTooltip content="DevLake is only concerned with deployments in production environment when calculating DORA metrics. A BitBucket build with a name that matches the given RegEx will be considered as a job in the Production environment. If you leave this field empty, all data will be tagged as in the Production environment. " />
+                  </>
+                }
+              >
+                <InputGroup
+                  placeholder="(?i)production"
+                  value={transformation.productionPattern}
+                  onChange={(e) =>
+                    setTransformation({
+                      ...transformation,
+                      productionPattern: e.target.value,
+                    })
                   }
-                >
-                  <InputGroup
-                    placeholder="(?i)production"
-                    value={transformation.productionPattern}
-                    onChange={(e) =>
-                      setTransformation({
-                        ...transformation,
-                        productionPattern: e.target.value,
-                      })
-                    }
-                  />
-                </FormGroup>
-              </div>
-            </>
-          )}
-          <Radio label="Not using any Bitbucket entities as Deployment" value={0} />
-        </RadioGroup>
+                />
+              </FormGroup>
+            </div>
+          </>
+        )}
       </div>
       <Divider />
       {/* Additional Settings */}