artifactory
This module provides functions for uploading build artifacts and related files to your Artifactory instanceExample
no available example in current language
// Upload an artifact with evidence
func (m *Example) Artifactory(
ctx context.Context,
instanceURL string,
accessToken *dagger.Secret,
) (string, error) {
// Construct the artifactory module
client := dag.Artifactory(accessToken, instanceURL)
// Upload an artifact
artifact := dag.HTTP(
"https://github.com/dagger/dagger/releases/download/v0.18.13/dagger_v0.18.13_linux_amd64.tar.gz",
)
artifactPath := "generic-repo/dagger_v0.18.13_linux_amd64.tar.gz"
uploadOutput, err := client.Upload(ctx, artifact, artifactPath)
if err != nil {
return "", err
}
// Wait a moment for upload to process
time.Sleep(1 * time.Second)
// Upload evidence for the artifact
predicate := dag.
CurrentModule().
Source().
File("./test_predicate.json")
predicateType := "https://in-toto.io/Statement/v1"
key := dag.CurrentModule().Source().File("./private.pem")
keyAlias := "OtherKey"
traceURL, err := dag.Cloud().TraceURL(ctx)
if err != nil {
return "", err
}
createEvidenceOutput, err := client.CreateEvidence(
ctx,
predicate,
predicateType,
key,
dagger.ArtifactoryCreateEvidenceOpts{
KeyAlias: keyAlias,
SubjectRepoPath: artifactPath,
TraceURL: traceURL,
})
return fmt.Sprintf("%s\n%s", uploadOutput, createEvidenceOutput), nil
}
no available example in current language
/**
* Upload an artifact with evidence
*/
@func()
async artifactory(instanceUrl: string, accessToken: Secret): Promise<string> {
// Construct the artifactory module
const client = dag.artifactory(accessToken, instanceUrl);
// Upload an artifact
const artifact = dag.http(
"https://github.com/dagger/dagger/releases/download/v0.18.13/dagger_v0.18.13_linux_amd64.tar.gz",
);
const artifactPath = "generic-repo/dagger_v0.18.13_linux_amd64.tar.gz";
const uploadOutput = await client.upload(artifact, artifactPath);
// Wait a moment for upload to process
await new Promise((resolve) => setTimeout(resolve, 1000));
// Upload evidence for the artifact
const predicate = dag
.currentModule()
.source()
.file("./test_predicate.json");
const predicateType = "https://in-toto.io/Statement/v1";
const key = dag.currentModule().source().file("./private.pem");
const keyAlias = "OtherKey";
const traceUrl = await dag.cloud().traceURL();
const createEvidenceOutput = await client.createEvidence(
predicate,
predicateType,
key,
{ keyAlias: keyAlias, subjectRepoPath: artifactPath, traceUrl: traceUrl },
);
return uploadOutput + "\n" + createEvidenceOutput;
}
Installation
dagger install github.com/kpenfound/dag/artifactory@v1.0.4
Entrypoint
Return Type
Artifactory !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
accessToken | Secret ! | - | Artifactory access token |
url | String ! | - | Jfrog Artifactory API URL. It usually ends with /artifactory |
cliVersion | String ! | "2.78.0" | Jfrog CLI version |
Example
dagger -m github.com/kpenfound/dag/artifactory@aa7859c7bafe678536a961aea792986734851db3 call \
--access-token env:MYSECRET --url string --cli-version string
func (m *MyModule) Example(accessToken *dagger.Secret, url string, cliVersion string) *dagger.Artifactory {
return dag.
Artifactory(accessToken, url, cliVersion)
}
@function
def example(access_token: dagger.Secret, url: str, cli_version: str) -> dagger.Artifactory:
return (
dag.artifactory(access_token, url, cli_version)
)
@func()
example(accessToken: Secret, url: string, cliVersion: string): Artifactory {
return dag
.artifactory(accessToken, url, cliVersion)
}
Types
Artifactory 🔗
upload() 🔗
Upload any file to artifactory
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
file | File ! | - | file to upload |
targetPath | String ! | - | path in artifactory to upload to |
extraFlags | [String ! ] | - | extra arguments for jf cli |
Example
dagger -m github.com/kpenfound/dag/artifactory@aa7859c7bafe678536a961aea792986734851db3 call \
--access-token env:MYSECRET --url string --cli-version string upload --file file:path --target-path string
func (m *MyModule) Example(ctx context.Context, accessToken *dagger.Secret, url string, cliVersion string, file *dagger.File, targetPath string) string {
return dag.
Artifactory(accessToken, url, cliVersion).
Upload(ctx, file, targetPath)
}
@function
async def example(access_token: dagger.Secret, url: str, cli_version: str, file: dagger.File, target_path: str) -> str:
return await (
dag.artifactory(access_token, url, cli_version)
.upload(file, target_path)
)
@func()
async example(accessToken: Secret, url: string, cliVersion: string, file: File, targetPath: string): Promise<string> {
return dag
.artifactory(accessToken, url, cliVersion)
.upload(file, targetPath)
}
createEvidence() 🔗
Upload evidence to a resource in Artifactory
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
predicate | File ! | - | predicate File to attach as evidence |
predicateType | String ! | - | predicate type based on in-toto attestation predicates |
key | File ! | - | private key to sign DSSE envelope |
keyAlias | String | - | key alias for a public key that exists in your Artifactory instance to validate the signature |
subjectRepoPath | String | - | If the resource is an Artifact, a path to the artifact |
packageName | String | - | If the resource is a Package, the name of the package |
packageVersion | String | - | If the resource is a Package, the version of the package |
packageRepoName | String | - | If the resource is a Package, the name of the package repo |
buildName | String | - | If the resource is a Build, the name of the build |
buildNumber | String | - | If the resource is a Build, the number of the build |
releaseBundleName | String | - | If the resource is a Release Bundle, the name of the release bundle |
releaseBundleVersion | String | - | If the resource is a Release Bundle, the version of the release bundle |
extraArgs | [String ! ] | - | extra flags to pass through to jf cli |
traceUrl | String | - | dagger cloud trace URL to attach to evidence |
Example
dagger -m github.com/kpenfound/dag/artifactory@aa7859c7bafe678536a961aea792986734851db3 call \
--access-token env:MYSECRET --url string --cli-version string create-evidence --predicate file:path --predicate-type string --key file:path
func (m *MyModule) Example(ctx context.Context, accessToken *dagger.Secret, url string, cliVersion string, predicate *dagger.File, predicateType string, key *dagger.File) string {
return dag.
Artifactory(accessToken, url, cliVersion).
CreateEvidence(ctx, predicate, predicateType, key)
}
@function
async def example(access_token: dagger.Secret, url: str, cli_version: str, predicate: dagger.File, predicate_type: str, key: dagger.File) -> str:
return await (
dag.artifactory(access_token, url, cli_version)
.create_evidence(predicate, predicate_type, key)
)
@func()
async example(accessToken: Secret, url: string, cliVersion: string, predicate: File, predicateType: string, key: File): Promise<string> {
return dag
.artifactory(accessToken, url, cliVersion)
.createEvidence(predicate, predicateType, key)
}
jfExec() 🔗
Run a command with the jf CLI
Return Type
Container !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
args | [String ! ] ! | - | arguments to pass to jf cli |
Example
dagger -m github.com/kpenfound/dag/artifactory@aa7859c7bafe678536a961aea792986734851db3 call \
--access-token env:MYSECRET --url string --cli-version string jf-exec --args string1 --args string2
func (m *MyModule) Example(accessToken *dagger.Secret, url string, cliVersion string, args []string) *dagger.Container {
return dag.
Artifactory(accessToken, url, cliVersion).
JfExec(args)
}
@function
def example(access_token: dagger.Secret, url: str, cli_version: str, args: List[str]) -> dagger.Container:
return (
dag.artifactory(access_token, url, cli_version)
.jf_exec(args)
)
@func()
example(accessToken: Secret, url: string, cliVersion: string, args: string[]): Container {
return dag
.artifactory(accessToken, url, cliVersion)
.jfExec(args)
}
cli() 🔗
Get a Container with the jf CLI installed
Return Type
Container !
Example
dagger -m github.com/kpenfound/dag/artifactory@aa7859c7bafe678536a961aea792986734851db3 call \
--access-token env:MYSECRET --url string --cli-version string cli
func (m *MyModule) Example(accessToken *dagger.Secret, url string, cliVersion string) *dagger.Container {
return dag.
Artifactory(accessToken, url, cliVersion).
Cli()
}
@function
def example(access_token: dagger.Secret, url: str, cli_version: str) -> dagger.Container:
return (
dag.artifactory(access_token, url, cli_version)
.cli()
)
@func()
example(accessToken: Secret, url: string, cliVersion: string): Container {
return dag
.artifactory(accessToken, url, cliVersion)
.cli()
}