apache / incubator-devlake

Apache DevLake is an open-source dev data platform to ingest, analyze, and visualize the fragmented data from DevOps tools, extracting insights for engineering excellence, developer experience, and community growth.
https://devlake.apache.org/
Apache License 2.0
2.5k stars 492 forks source link

[Question][Module Name] cant connect to Jira #7521

Open chrisolido opened 1 month ago

chrisolido commented 1 month ago

Question

I am trying to connect to my JIRA cloud and its always failing when testing and and run the pipeline to sync failed to get server info image

please help what i am doing wring here? (Newbie)

Screenshots

image Telling me its failing.

reason is this. image

Additional context

Add any other context here.

dosubot[bot] commented 1 month ago

To resolve the issues you're facing with connecting to your JIRA cloud instance and the errors in your Jenkins pipeline, follow these steps:

JIRA Cloud Connection

  1. Endpoint URL: Ensure the endpoint URL is in the correct format and ends with a /. For JIRA Cloud, it should be something like https://your-company.atlassian.net/rest/.

  2. Authentication: Use your email and an API token for authentication. Here is an example of how to set these fields:

<Block
  style={{ marginTop: 8, marginBottom: 0 }}
  title="Endpoint URL"
  description={
    <>
      {version === 'cloud'
        ? 'Provide the Jira instance API endpoint. For Jira Cloud, e.g. https://your-company.atlassian.net/rest/. Please note that the endpoint URL should end with /.'
        : ''}
    </>
  }
  required
>
  <Input
    style={{ width: 386 }}
    placeholder="Your Endpoint URL"
    value={values.endpoint}
    onChange={handleChangeEndpoint}
  />
</Block>

{version === 'cloud' && (
  <>
    <Block title="E-Mail" required>
      <Input
        style={{ width: 386 }}
        placeholder="Your E-Mail"
        value={values.username}
        onChange={handleChangeUsername}
      />
    </Block>
    <Block
      title="API Token"
      description={
        <ExternalLink link={DOC_URL.PLUGIN.JIRA.API_TOKEN}>Learn about how to create an API Token</ExternalLink>
      }
      required
    >
      <Input
        style={{ width: 386 }}
        placeholder={type === 'update' ? '********' : 'Your PAT'}
        value={values.password}
        onChange={handleChangePassword}
      />
    </Block>
  </>
)}

Ensure that:

Jenkins Pipeline Errors

For the "unsupported protocol scheme" and "unexpected status code 404" errors in your Jenkins pipeline, you can modify the execCloneCommand function to handle these specific errors. Here is an example:

func (g *GitcliCloner) execCloneCommand(cmd *exec.Cmd) errors.Error {
    stdout, err := cmd.StdoutPipe()
    if err != nil {
        g.logger.Error(err, "stdout pipe error")
        return errors.Default.New("stdout pipe error")
    }
    stderr, err := cmd.StderrPipe()
    if err != nil {
        g.logger.Error(err, "stderr pipe error")
        return errors.Default.New("stderr pipe error")
    }
    combinedOutput := new(strings.Builder)
    stdoutScanner := bufio.NewScanner(stdout)
    stdoutScanner.Split(bufio.ScanLines)
    stderrScanner := bufio.NewScanner(stderr)
    stderrScanner.Split(bufio.ScanLines)
    done := make(chan bool)
    go func() {
        for stdoutScanner.Scan() {
            combinedOutput.WriteString(fmt.Sprintf("stdout: %s\n", stdoutScanner.Text()))
        }
        done <- true
    }()
    go func() {
        for stderrScanner.Scan() {
            combinedOutput.WriteString(fmt.Sprintf("stderr: %s\n", stderrScanner.Text()))
        }
        done <- true
    }()
    if e := cmd.Start(); e != nil {
        g.logger.Error(e, "failed to start\n%s", combinedOutput.String())
        return errors.Default.New("failed to start")
    }
    <-done
    <-done
    err = cmd.Wait()
    if err != nil {
        g.logger.Error(err, "git exited with error\n%s", combinedOutput.String())
        if strings.Contains(combinedOutput.String(), "stderr: fatal: error processing shallow info: 4") ||
            strings.Contains(combinedOutput.String(), "stderr: fatal: the remote end hung up unexpectedly") {
            return ErrNoData
        }
        if strings.Contains(combinedOutput.String(), "stderr: fatal: repository not found") ||
            strings.Contains(combinedOutput.String(), "unexpected status code 404") {
            return errors.Default.New("repository not found (404)")
        }
        return errors.Default.New("git exit error")
    }
    return nil
}

This code checks for the "unexpected status code 404" error and handles it by returning a specific error message, which will help you identify and address the issue in your Jenkins pipeline [1][2].

Environment Variables for Jenkins

Ensure that the following environment variables are set for Jenkins to work seamlessly with incubator-devlake:

JENKINS_ENDPOINT=
JENKINS_USERNAME=
JENKINS_PASSWORD=

Additionally, make sure other core configurations such as PLUGIN_DIR, DB_URL, and PORT are properly set as per your setup requirements [3][4][5][6].

By following these steps, you should be able to resolve the connection issues with your JIRA cloud instance and the errors in your Jenkins pipeline.

#### Details **About Dosu** This response is meant to be useful and save you time. It is **not meant to be a precise solution**, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

To continue the conversation, mention @dosu.

klesh commented 1 month ago

Try adding /rest suffix to your endpoint.