hashicorp/packer · error

JENKINS_URL environment variable not found

Error message

JENKINS_URL environment variable not found

What it means

CI/CD environment detection for HCP Packer registry metadata. JenkinsCI.Detect probes for the JENKINS_URL variable that Jenkins exports to pipeline jobs; this error means Packer was not running on a Jenkins build agent, so this detector does not apply. It is benign when another CI detector succeeds, and only matters if Jenkins metadata was expected, in which case confirm the build runs inside a Jenkins job.

Source

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

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

	return env
}

func (b *BitbucketPipelines) Type() string {
	return "bitbucket"
}

type JenkinsCI struct{}

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

func (g *JenkinsCI) Details() map[string]interface{} {
	env := make(map[string]interface{})
	keys := []string{
		"JENKINS_URL",
		"BUILD_URL",
		"NODE_NAME",
		"JOB_NAME",
		"JOB_URL",
		"BUILD_NUMBER",
		"BUILD_ID",
		"BUILD_TAG",
		"WORKSPACE",
		"BUILD_CAUSE",
		"GIT_COMMIT",

View on GitHub (pinned to eb36e3c3e4)

Solutions

  1. Expected negative detection; try the next CI provider in the chain
  2. Run the build as a Jenkins job if Jenkins metadata is required
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at internal/hcp/registry/metadata/cicd.go:137 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/0afd8ecd5be5f55a. Report an issue: GitHub.