incubator-devlake icon indicating copy to clipboard operation
incubator-devlake copied to clipboard

[Question][Module Name] cant connect to Jira

Open chrisolido opened this issue 1 year ago • 2 comments

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.

chrisolido avatar May 27 '24 08:05 chrisolido

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:

  • The endpoint field is correctly set to your JIRA Cloud instance URL.
  • The username field contains your email.
  • The password field contains your API token.

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.

dosubot[bot] avatar May 27 '24 08:05 dosubot[bot]

Try adding /rest suffix to your endpoint.

klesh avatar May 30 '24 10:05 klesh

This issue has been automatically marked as stale because it has been inactive for 60 days. It will be closed in next 7 days if no further activity occurs.

github-actions[bot] avatar Jul 30 '24 00:07 github-actions[bot]

This issue has been closed because it has been inactive for a long time. You can reopen it if you encounter the similar problem in the future.

github-actions[bot] avatar Aug 06 '24 00:08 github-actions[bot]