Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/attestation/crafter/runners/daggerpipeline.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 The Chainloop Authors.
// Copyright 2024-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,6 +45,20 @@ func (r *DaggerPipeline) ListEnvVars() []*EnvVarDefinition {
return []*EnvVarDefinition{
// Version of the Chainloop Client
{"CHAINLOOP_DAGGER_CLIENT", false},
// Github Actions PR-specific variables (optional - only present in PR contexts)
{"GITHUB_EVENT_NAME", true},
{"GITHUB_HEAD_REF", true},
{"GITHUB_BASE_REF", true},
{"GITHUB_EVENT_PATH", true},
// Gitlab CI MR-specific variables (optional - only present in MR contexts)
{"CI_PIPELINE_SOURCE", true},
{"CI_MERGE_REQUEST_IID", true},
{"CI_MERGE_REQUEST_TITLE", true},
{"CI_MERGE_REQUEST_DESCRIPTION", true},
{"CI_MERGE_REQUEST_SOURCE_BRANCH_NAME", true},
{"CI_MERGE_REQUEST_TARGET_BRANCH_NAME", true},
{"CI_MERGE_REQUEST_PROJECT_URL", true},
{"GITLAB_USER_LOGIN", true},
}
}

Expand Down
23 changes: 20 additions & 3 deletions pkg/attestation/crafter/runners/daggerpipeline_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 The Chainloop Authors.
// Copyright 2024-2026 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -62,13 +62,30 @@ func (s *daggerPipelineSuite) TestCheckEnv() {
}

func (s *daggerPipelineSuite) TestListEnvVars() {
assert.Equal(s.T(), []*EnvVarDefinition{{"CHAINLOOP_DAGGER_CLIENT", false}}, s.runner.ListEnvVars())
expected := []*EnvVarDefinition{
{"CHAINLOOP_DAGGER_CLIENT", false},
// Github Actions PR-specific variables
{"GITHUB_EVENT_NAME", true},
{"GITHUB_HEAD_REF", true},
{"GITHUB_BASE_REF", true},
{"GITHUB_EVENT_PATH", true},
// Gitlab CI MR-specific variables
{"CI_PIPELINE_SOURCE", true},
{"CI_MERGE_REQUEST_IID", true},
{"CI_MERGE_REQUEST_TITLE", true},
{"CI_MERGE_REQUEST_DESCRIPTION", true},
{"CI_MERGE_REQUEST_SOURCE_BRANCH_NAME", true},
{"CI_MERGE_REQUEST_TARGET_BRANCH_NAME", true},
{"CI_MERGE_REQUEST_PROJECT_URL", true},
{"GITLAB_USER_LOGIN", true},
}
assert.Equal(s.T(), expected, s.runner.ListEnvVars())
}

func (s *daggerPipelineSuite) TestResolveEnvVars() {
resolvedEnvVars, errors := s.runner.ResolveEnvVars()
s.Empty(errors)
s.Equal(map[string]string{"CHAINLOOP_DAGGER_CLIENT": "v0.6.0"}, resolvedEnvVars)
s.Equal("v0.6.0", resolvedEnvVars["CHAINLOOP_DAGGER_CLIENT"])
}

func (s *daggerPipelineSuite) TestRunURI() {
Expand Down
Loading