aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/deliverable.h3
-rw-r--r--src/deliverable.c33
-rw-r--r--src/main.c2
3 files changed, 21 insertions, 17 deletions
diff --git a/include/deliverable.h b/include/deliverable.h
index d712d08..04967c8 100644
--- a/include/deliverable.h
+++ b/include/deliverable.h
@@ -156,9 +156,10 @@ struct Delivery {
} tests[1000]; ///< An array of tests
struct Deploy {
+ struct JFRT_Auth jfrog_auth;
+
struct JFrog {
struct StrList *files;
- struct JFRT_Auth auth_ctx;
struct JFRT_Upload upload_ctx;
char *repo;
char *dest;
diff --git a/src/deliverable.c b/src/deliverable.c
index c535c06..5112d09 100644
--- a/src/deliverable.c
+++ b/src/deliverable.c
@@ -1617,59 +1617,60 @@ int delivery_init_artifactory(struct Delivery *ctx) {
int delivery_artifact_upload(struct Delivery *ctx) {
int status = 0;
+ if (jfrt_auth_init(&ctx->deploy.jfrog_auth)) {
+ fprintf(stderr, "Failed to initialize Artifactory authentication context\n");
+ return -1;
+ }
+
for (size_t i = 0; i < sizeof(ctx->deploy.jfrog) / sizeof(*ctx->deploy.jfrog); i++) {
if (!ctx->deploy.jfrog[i].files || !ctx->deploy.jfrog[i].dest) {
break;
}
jfrt_upload_init(&ctx->deploy.jfrog[i].upload_ctx);
- char *repo = getenv("OMC_JF_REPO");
- if (repo) {
- ctx->deploy.jfrog[i].repo = strdup(repo);
- } else if (globals.jfrog.repo) {
- ctx->deploy.jfrog[i].repo = strdup(globals.jfrog.repo);
- } else {
+ if (!globals.jfrog.repo) {
msg(OMC_MSG_WARN, "Artifactory repository path is not configured!\n");
fprintf(stderr, "set OMC_JF_REPO environment variable...\nOr append to configuration file:\n\n");
fprintf(stderr, "[deploy:artifactory]\nrepo = example/generic/repo/path\n\n");
status++;
break;
+ } else if (!ctx->deploy.jfrog[i].repo) {
+ ctx->deploy.jfrog[i].repo = strdup(globals.jfrog.repo);
}
- if (isempty(ctx->deploy.jfrog[i].repo) || !strlen(ctx->deploy.jfrog[i].repo)) {
+ if (!ctx->deploy.jfrog[i].repo || isempty(ctx->deploy.jfrog[i].repo) || !strlen(ctx->deploy.jfrog[i].repo)) {
// Unlikely to trigger if the config parser is working correctly
msg(OMC_MSG_ERROR, "Artifactory repository path is empty. Cannot continue.\n");
status++;
break;
}
- if (jfrt_auth_init(&ctx->deploy.jfrog[i].auth_ctx)) {
- continue;
- }
-
ctx->deploy.jfrog[i].upload_ctx.workaround_parent_only = true;
ctx->deploy.jfrog[i].upload_ctx.build_name = ctx->info.build_name;
ctx->deploy.jfrog[i].upload_ctx.build_number = ctx->info.build_number;
char files[PATH_MAX];
+ char dest[PATH_MAX]; // repo + remote dir
- if (jfrog_cli_rt_ping(&ctx->deploy.jfrog[i].auth_ctx)) {
- msg(OMC_MSG_ERROR | OMC_MSG_L2, "Unable to contact artifactory server: %s\n", ctx->deploy.jfrog[i].auth_ctx.url);
+ if (jfrog_cli_rt_ping(&ctx->deploy.jfrog_auth)) {
+ msg(OMC_MSG_ERROR | OMC_MSG_L2, "Unable to contact artifactory server: %s\n", ctx->deploy.jfrog_auth.url);
return -1;
}
if (strlist_count(ctx->deploy.jfrog[i].files)) {
for (size_t f = 0; f < strlist_count(ctx->deploy.jfrog[i].files); f++) {
+ memset(dest, 0, sizeof(dest));
memset(files, 0, sizeof(files));
+ snprintf(dest, sizeof(dest) - 1, "%s/%s", ctx->deploy.jfrog[i].repo, ctx->deploy.jfrog[i].dest);
snprintf(files, sizeof(files) - 1, "%s", strlist_item(ctx->deploy.jfrog[i].files, f));
- status += jfrog_cli_rt_upload(&ctx->deploy.jfrog[i].auth_ctx, &ctx->deploy.jfrog[i].upload_ctx, files, ctx->deploy.jfrog[i].dest);
+ status += jfrog_cli_rt_upload(&ctx->deploy.jfrog_auth, &ctx->deploy.jfrog[i].upload_ctx, files, dest);
}
}
}
if (!status && ctx->deploy.jfrog[0].files && ctx->deploy.jfrog[0].dest) {
- jfrog_cli_rt_build_collect_env(&ctx->deploy.jfrog[0].auth_ctx, ctx->deploy.jfrog[0].upload_ctx.build_name, ctx->deploy.jfrog[0].upload_ctx.build_number);
- jfrog_cli_rt_build_publish(&ctx->deploy.jfrog[0].auth_ctx, ctx->deploy.jfrog[0].upload_ctx.build_name, ctx->deploy.jfrog[0].upload_ctx.build_number);
+ jfrog_cli_rt_build_collect_env(&ctx->deploy.jfrog_auth, ctx->deploy.jfrog[0].upload_ctx.build_name, ctx->deploy.jfrog[0].upload_ctx.build_number);
+ jfrog_cli_rt_build_publish(&ctx->deploy.jfrog_auth, ctx->deploy.jfrog[0].upload_ctx.build_name, ctx->deploy.jfrog[0].upload_ctx.build_number);
}
return status;
diff --git a/src/main.c b/src/main.c
index 81cc1a4..5da1a97 100644
--- a/src/main.c
+++ b/src/main.c
@@ -132,6 +132,7 @@ void globals_free() {
guard_strlist_free(&globals.pip_packages);
guard_free(globals.jfrog.arch);
guard_free(globals.jfrog.os);
+ guard_free(globals.jfrog.url);
guard_free(globals.jfrog.repo);
guard_free(globals.jfrog.version);
guard_free(globals.jfrog.cli_major_ver);
@@ -256,6 +257,7 @@ int main(int argc, char *argv[]) {
tpl_register("conda.installer_arch", &ctx.conda.installer_arch);
tpl_register("conda.installer_platform", &ctx.conda.installer_platform);
tpl_register("deploy.jfrog.repo", &globals.jfrog.repo);
+ tpl_register("deploy.jfrog.url", &globals.jfrog.url);
tpl_register("deploy.docker.registry", &ctx.deploy.docker.registry);
tpl_register("workaround.tox_posargs", &globals.workaround.tox_posargs);