hashicorp/packer · error

BITBUCKET_BUILD_NUMBER environment variable not found

Error message

BITBUCKET_BUILD_NUMBER environment variable not found

What it means

Probe result from the Bitbucket Pipelines detector (BitbucketPipelines.Detect): the BITBUCKET_BUILD_NUMBER env var is absent, so the process is not running inside Bitbucket Pipelines and this metadata provider does not apply.

Source

Thrown at internal/hcp/registry/metadata/cicd.go:95

	for _, key := range keys {
		if value, ok := os.LookupEnv(key); ok {
			env[key] = value
		}
	}

	return env
}

func (g *GitlabCI) Type() string {
	return "gitlab"
}

type BitbucketPipelines struct{}

func (b *BitbucketPipelines) Detect() error {
	_, ok := os.LookupEnv("BITBUCKET_BUILD_NUMBER")
	if !ok {
		return fmt.Errorf("BITBUCKET_BUILD_NUMBER environment variable not found")
	}
	return nil
}

func (b *BitbucketPipelines) Details() map[string]interface{} {
	env := make(map[string]interface{})
	keys := []string{
		"BITBUCKET_REPO_FULL_NAME",
		"BITBUCKET_REPO_UUID",
		"BITBUCKET_WORKSPACE",
		"BITBUCKET_COMMIT",
		"BITBUCKET_BRANCH",
		"BITBUCKET_TAG",
		"BITBUCKET_BUILD_NUMBER",
		"BITBUCKET_PIPELINE_UUID",
		"BITBUCKET_STEP_UUID",
		"BITBUCKET_DEPLOYMENT_ENVIRONMENT",
		"BITBUCKET_PR_ID",

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Expected negative detection; try the next CI provider in the chain
  2. Run the build inside a Bitbucket Pipeline if its metadata is required
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/hcp/registry/metadata/cicd.go:95 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of hashicorp/packer@eb36e3c3e4 (2026-09-05). Data as JSON: /api/errors/03c0fcdb20ec829e. Report an issue: GitHub.