STASIS
A pipeline delivery generator
Loading...
Searching...
No Matches
artifactory.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include "core.h"
#include "download.h"
Include dependency graph for artifactory.h:

Go to the source code of this file.

Data Structures

struct  JFRT_Auth
 JFrog Artifactory Authentication struct. More...
 
struct  JFRT_Upload
 JFrog Artifactory Upload struct. More...
 
struct  JFRT_Download
 
struct  JFRT_Search
 

Functions

int artifactory_download_cli (char *dest, char *jfrog_artifactory_base_url, char *jfrog_artifactory_product, char *cli_major_ver, char *version, char *os, char *arch, char *remote_filename)
 
int jfrog_cli (struct JFRT_Auth *auth, const char *subsystem, const char *task, char *args)
 
int jfrog_cli_rt_ping (struct JFRT_Auth *auth)
 
int jfrog_cli_rt_upload (struct JFRT_Auth *auth, struct JFRT_Upload *ctx, char *src, char *repo_path)
 
int jfrog_cli_rt_download (struct JFRT_Auth *auth, struct JFRT_Download *ctx, char *repo_path, char *dest)
 
int jfrog_cli_rt_search (struct JFRT_Auth *auth, struct JFRT_Search *ctx, char *repo_path, char *pattern)
 
int jfrog_cli_rt_build_collect_env (struct JFRT_Auth *auth, char *build_name, char *build_number)
 
int jfrog_cli_rt_build_publish (struct JFRT_Auth *auth, char *build_name, char *build_number)
 
int jfrt_auth_init (struct JFRT_Auth *auth_ctx)
 
void jfrt_upload_init (struct JFRT_Upload *ctx)
 

Function Documentation

◆ artifactory_download_cli()

int artifactory_download_cli ( char * dest,
char * jfrog_artifactory_base_url,
char * jfrog_artifactory_product,
char * cli_major_ver,
char * version,
char * os,
char * arch,
char * remote_filename )

Download the JFrog CLI tool from jfrog.com

"https://releases.jfrog.io/artifactory",
"jfrog-cli",
"v2-jf",
"[RELEASE]",
"Linux",
"x86_64",
"jf") {
remove("./jf");
fprintf(stderr, "Failed to download JFrog CLI\n");
exit(1);
}
int artifactory_download_cli(char *dest, char *jfrog_artifactory_base_url, char *jfrog_artifactory_product, char *cli_major_ver, char *version, char *os, char *arch, char *remote_filename)
Definition artifactory.c:3
Parameters
destDirectory path
jfrog_artifactory_base_urljfrog.com base URL
jfrog_artifactory_productjfrog.com project (jfrog-cli)
cli_major_verVersion series (v1, v2-jf, vX-jf)
versionVersion to download. "[RELEASE]" will download the latest version available
osOperating system name
archSystem CPU architecture
remote_filenameFile to download (jf)
Returns
Here is the call graph for this function:

◆ jfrog_cli()

int jfrog_cli ( struct JFRT_Auth * auth,
const char * subsystem,
const char * task,
char * args )

JFrog CLI binding. Executes the "jf" tool with arguments.

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
if (jfrog_cli(&auth_ctx, "rt", "ping", NULL) {
fprintf(stderr, "Failed to ping artifactory server: %s\n", auth_ctx.url);
exit(1);
}
int jfrog_cli(struct JFRT_Auth *auth, const char *subsystem, const char *task, char *args)
Definition artifactory.c:221
int jfrt_auth_init(struct JFRT_Auth *auth_ctx)
Definition artifactory.c:168
JFrog Artifactory Authentication struct.
Definition artifactory.h:11
char * user
Account to authenticate as.
Definition artifactory.h:19
Parameters
authJFRT_Auth structure
subsystem"jf" tool subsystem (i.e. "rt")
task"jf" tool task "upload", "download", etc
argsCommand line arguments to pass to "jf" tool
Returns
exit code from "jf"
Here is the call graph for this function:

◆ jfrog_cli_rt_build_collect_env()

int jfrog_cli_rt_build_collect_env ( struct JFRT_Auth * auth,
char * build_name,
char * build_number )

Collect runtime data for Artifactory build object.

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
if (jfrog_cli_rt_build_collect_env(&auth_ctx, "mybuildname", "1.2.3+gabcdef")) {
fprintf(stderr, "Failed to collect runtime data for Artifactory build object\n");
exit(1);
}
int jfrog_cli_rt_build_collect_env(struct JFRT_Auth *auth, char *build_name, char *build_number)
Definition artifactory.c:288
Parameters
authJFRT_Auth structure
build_nameArtifactory build name
build_numberArtifactory build number
Returns
exit code from "jf"

◆ jfrog_cli_rt_build_publish()

int jfrog_cli_rt_build_publish ( struct JFRT_Auth * auth,
char * build_name,
char * build_number )

Publish build object to Artifactory server

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
if (jfrog_cli_rt_build_collect_env(&auth_ctx, "mybuildname", "1.2.3+gabcdef")) {
fprintf(stderr, "Failed to collect runtime data for Artifactory build object\n");
exit(1);
}
if (jfrog_cli_rt_build_publish(&auth_ctx, "mybuildname", "1.2.3+gabcdef")) {
fprintf(stderr, "Failed to publish Artifactory build object\n");
exit(1);
}
int jfrog_cli_rt_build_publish(struct JFRT_Auth *auth, char *build_name, char *build_number)
Definition artifactory.c:294
Parameters
authJFRT_Auth structure
build_nameArtifactory build name
build_numberArtifactory build number
Returns
exit code from "jf"

◆ jfrog_cli_rt_download()

int jfrog_cli_rt_download ( struct JFRT_Auth * auth,
struct JFRT_Download * ctx,
char * repo_path,
char * dest )

Download a file from an Artifactory repository

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
struct JFRT_Download download_ctx;
memset(download_ctx, 0, sizeof(download_ctx));
if (jfrt_cli_rt_download(&auth_ctx, &download_ctx,
"repo_name/ext_files/", "local/files_*.ext")) {
fprintf(stderr, "Upload failed\n");
exit(1);
}
Definition artifactory.h:54
Parameters
authJFRT_Auth structure
ctxJFRT_Download structure
repo_pathRemote repository w/ file pattern
destLocal destination path
Returns
exit code from "jf"
Here is the call graph for this function:

◆ jfrog_cli_rt_ping()

int jfrog_cli_rt_ping ( struct JFRT_Auth * auth)

Issue an Artifactory server ping

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
if (jfrog_cli_ping(&auth_ctx)) {
fprintf(stderr, "Failed to ping artifactory server: %s\n", auth_ctx.url);
exit(1);
}
Parameters
authJFRT_Auth structure
Returns
exit code from "jf"

◆ jfrog_cli_rt_search()

int jfrog_cli_rt_search ( struct JFRT_Auth * auth,
struct JFRT_Search * ctx,
char * repo_path,
char * pattern )

Search for files in an Artifactory repository

Parameters
authJFRT_Auth structure
ctxJFRT_Search structure
repo_pathRemote repository w/ file pattern
destLocal destination path
Returns
exit code from "jf"
Here is the call graph for this function:

◆ jfrog_cli_rt_upload()

int jfrog_cli_rt_upload ( struct JFRT_Auth * auth,
struct JFRT_Upload * ctx,
char * src,
char * repo_path )

Upload files to an Artifactory repository

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);
struct JFRT_Upload upload_ctx;
jfrt_upload_init(&upload_ctx);
if (jfrt_cli_rt_upload(&auth_ctx, &upload_ctx,
"local/files_*.ext", "repo_name/ext_files/")) {
fprintf(stderr, "Upload failed\n");
exit(1);
}
void jfrt_upload_init(struct JFRT_Upload *ctx)
Definition artifactory.c:148
JFrog Artifactory Upload struct.
Definition artifactory.h:25
Parameters
authJFRT_Auth structure
ctxJFRT_Upload structure
srclocal pattern to upload
repo_pathremote Artifactory destination path
Returns
exit code from "jf"
Here is the call graph for this function:

◆ jfrt_auth_init()

int jfrt_auth_init ( struct JFRT_Auth * auth_ctx)

Configure JFrog CLI authentication according to STASIS specs

This function will use the STASIS_JF_* environment variables to configure the authentication context. With this in mind, if an STASIS_JF_* environment variable is not defined, the original value of the structure member will be used instead.

Use STASIS_JF_* variables to configure context

struct JFRT_Auth auth_ctx;

Use your own input, but let the environment take over when variables are defined

struct JFRT_Auth auth_ctx;
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
jfrt_auth_init(&auth_ctx);

Use your own input without STASIS's help. Purely an illustrative example.

struct JFRT_Auth auth_ctx;
memset(auth_ctx, 0, sizeof(auth_ctx));
auth_ctx.user = strdup("myuser");
auth_ctx.password = strdup("mypassword");
auth_ctx.url = strdup("https://myserver.tld/artifactory");
Parameters
auth_ctx
Returns

◆ jfrt_upload_init()

void jfrt_upload_init ( struct JFRT_Upload * ctx)

Zero-out and apply likely defaults to a JFRT_Upload structure

Parameters
ctxJFRT_Upload structure