jfrog快速使用(一)

简介: jfrog快速使用

Doker安装

  1. 创建一个data目录用于数据持久化
mkdir data
chmod -R 777 ./data
  1. docker部署
docker run -it -d \
        --name artifactory \
        --restart always \
        -v $PWD/data/:/var/opt/jfrog/artifactory  \
        -p 18081:8081 \
        -p 18082:8082 \
        releases-docker.jfrog.io/jfrog/artifactory-oss:latest
  • 快速部署
docker pull docker.bintray.io/jfrog/artifactory-oss
docker  run -d -p 8081:8081 docker.bintray.io/jfrog/artifactory-oss
  1. 访问 http://localhost:18082/ui/
    默认账号:admin/password

测试

CURL测试

上传

# 如果v1.0不存在会自动创建
curl -X PUT -u 用户名:密码 -T app.jar jfrog地址:端口/artifactory/v1.0/
curl -u test:密码 -T el7upgradeSSHv8.5p1.tar.gz https://test.com:8081/artifactory/test/el7upgradeSSHv8.5p1.tar.gz
curl -X PUT -u ${JFROG_USER}:${JFROG_PWD} -T 1.txt "${ARTIFACTORY_URL}/temp/1.txt"
# deploy files with property
curl -X PUT -u ${JFROG_USER}:${JFROG_PWD} -T 1.sh "${ARTIFACTORY_URL}/temp/1.sh;retention.days=20;build_os=ubuntu-18.04;"

下载

wget --user test --password '密码' https://test.com:8082/artifactory/public-tools/anymatch-2.0.0.tgz
curl -u ${JFROG_USER}:${JFROG_PWD} -O ${ARTIFACTORY_URL}/temp/1.txt

copy 文件

curl -X POST -u ${JFROG_USER}:${JFROG_PWD} ${ARTIFACTORY_URL}/api/copy/temp/1.txt?to=temp/2.txt

删除

curl -X DELETE -u 用户名:密码 jfrog地址:端口/artifactory/v1.0/app.jar  #删除文件
curl -X DELETE -u 用户名:密码 jfrog地址:端口/artifactory/v1.0/ #删除目录
curl -X DELETE -u ${JFROG_USER}:${JFROG_PWD} ${ARTIFACTORY_URL}/temp/1.txt

支持删除整个目录

获取files list

curl -u ${JFROG_USER}:${JFROG_PWD} -X POST ${ARTIFACTORY_URL}/api/search/aql -H 'Content-Type: text/plain' -d \
    "items.find({ \
        \"type\" : \"file\", \
        \"repo\" : {\"\$eq\" : \"${atf_repo}\"}, \
        \"path\":{\"\$match\":\"${atf_path}*\"} \
        }).include(\"name\",\"repo\",\"path\",\"actual_md5\",\"type\")" | tee "${tmp_file}"

获取多少天创建的files list

curl -u ${JFROG_USER}:${JFROG_PWD} -X POST ${ARTIFACTORY_URL}/api/search/aql -H 'Content-Type: text/plain' -d \
    "items.find({ \
        \"type\" : \"file\", \
        \"repo\" : {\"\$eq\" : \"${repo}\"}, \
        \"\$or\": [\
          {\
            \"\$and\": [\
              {\
                \"created\": { \"\$before\":\"${retention_days}d\" }\
              }\
            ]\
          }\
        ]\
        }).include(\"name\",\"repo\",\"path\",\"actual_md5\",\"type\")" \
    | jq '.results' \
    | jq '.[] |  "\(.repo)/\(.path)/\(.name)"' \
    | sed 's/"//g' \
    | sed "s#^#${ARTIFACTORY_URL}/#g"

java测试

参考

<dependency>
    <groupId>org.jfrog.artifactory.client</groupId>
    <artifactId>artifactory-java-client-services</artifactId>
    <version>RELEASE</version>
</dependency>
import org.jfrog.artifactory.client.Artifactory;
import org.jfrog.artifactory.client.ArtifactoryClientBuilder;
import org.jfrog.artifactory.client.model.File;
import org.jfrog.artifactory.client.model.RepoPath;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
public class JFrogConnectionTest {
    @Test
    public void test0() throws IOException {
        Artifactory artifactory = ArtifactoryClientBuilder.create()
                .setUrl("ArtifactoryUrl")
                .setUsername("username")
                .setPassword("password")
                .build();
        // 上传
        java.io.File file = new java.io.File("fileToUpload.txt");
        File result = artifactory.repository("RepoName").upload("path/to/newName.txt", file).doUpload();
        // 下载
        InputStream iStream = artifactory.repository("RepoName")
                .download("path/to/fileToDownload.txt")
                .doDownload();
    FileOutputStream fos = new FileOutputStream("b.txt");
    byte[] b = new byte[1024];
    int length;
    while((length= iStream.read(b)) > 0){
      fos.write(b,0,length);
    }
    iStream.close();
    fos.close();
        // 搜索
        List<RepoPath> searchItems = artifactory.searches()
                .repositories("RepoName", "RepoName2")
                .artifactsByName("prefixedWith*.txt")
                .doSearch();
        for (RepoPath searchItem : searchItems) {
            String repoKey = searchItem.getRepoKey();
            String itemPath = searchItem.getItemPath();
        }
        // 关闭Artifactory实例
        artifactory.close();
    }
}

上传应用

  1. 生成配置生成Artifactory仓库上传配置文件,选择仓库,点击‘Set Me Up’查看部署配置
相关文章
|
Kubernetes 关系型数据库 MySQL
制品库 Jfrog Artifactory 搭建私服
JFrog Artifactory 功能最强大的二进制制品仓库。在 Google、Apple、思科、甲骨文、华为、腾讯等众多世界500强公司中都有大规模使用,在二进制软件制品管理领域处于绝对领先地位。与其他服务不同,JJFrog Artifactory 在版本发行上分类较多且杂。
2336 0
制品库 Jfrog Artifactory 搭建私服
|
安全
Gitlab配置webhook报错:Urlis blocked: Requests to the local netwo..解决
Gitlab配置webhook报错:Urlis blocked: Requests to the local netwo..解决
1383 0
|
5月前
|
监控 Java 关系型数据库
解决 GitLab 响应超时:清理日志 + 重启服务一步到位
本文记录了一次GitLab响应超时问题的排查与解决过程。因Java项目日志堆积导致磁盘空间耗尽,引发GitLab服务卡顿甚至无法访问。通过“网络→服务→资源”的排查思路,定位到根分区使用率达98%,清理历史日志并重启GitLab后恢复正常。文中详细分享了操作步骤,并给出配置日志轮转、监控磁盘空间等避坑建议,帮助运维和开发人员快速应对类似故障,提升系统稳定性。
421 1
|
Rust 前端开发 API
Tauri 开发实践 — Tauri HTTP 请求开发
本文介绍了如何在 Tauri 中发起 HTTP 请求。首先通过安装 Tauri 生态中的工具包并配置 `tauri.conf.json` 文件来允许特定域名的 HTTP 通信。接着封装了一个简单的 HTTP 客户端类,并在页面中使用该客户端实现 GET 和 POST 请求。最后提供了完整的源码地址以供参考。此功能使得桌面应用能够与远程服务器进行交互,增强了应用的实用性。
1384 1
Tauri 开发实践 — Tauri HTTP 请求开发
|
人工智能 搜索推荐 IDE
MCP 是什么?一文看懂模型上下文协议
MCP(模型上下文协议)由Anthropic于2024年推出,旨在解决AI大模型的数据滞后问题,通过连接第三方数据源提升回答的时效性和相关性。传统联网搜索依赖公开信息,难以满足行业内部或定制化需求。MCP提供统一标准,使开发者能安全双向连接数据源与AI工具,简化集成流程。例如,Apifox MCP Server可将API文档作为数据源提供给支持MCP的IDE,助力智能代码生成。未来,MCP有望推动AI工具从封闭系统转向开放协作网络,显著提升开发效率与创新能力。
|
机器学习/深度学习 自然语言处理 自动驾驶
如何看待LangChain与智能Agent,二者有什么区别
LangChain是一种专注于自然语言处理的框架,通过链式结构连接多个模型组件,实现复杂任务如问答、对话生成等。其六大核心组件包括模型、检索、代理、链、记忆和回调,帮助开发者快速构建基于大语言模型的应用。智能Agent则是一种能够感知环境、推理决策并采取行动的智能体,涵盖更广泛的智能行为,如自动驾驶、智能家居等。两者分别侧重于语言处理和全面智能行为的技术实现,为不同应用场景提供强大支持。
974 0
|
弹性计算 安全 API
HTTP 405 Method Not Allowed:解析与解决
本文详细解析了HTTP 405 &quot;Method Not Allowed&quot; 错误,包括其定义、常见原因、示例代码及解决方案。通过检查API文档、修改请求方法或更新服务器配置,可有效解决此错误,提升Web开发效率。
10122 2
|
运维 Kubernetes 监控
Loki+Promtail+Grafana监控K8s日志
综上,Loki+Promtail+Grafana 监控组合对于在 K8s 环境中优化日志管理至关重要,它不仅提供了强大且易于扩展的日志收集与汇总工具,还有可视化这些日志的能力。通过有效地使用这套工具,可以显著地提高对应用的运维监控能力和故障诊断效率。
2413 0
|
jenkins Java API
jenkins API实践
jenkins API实践
|
jenkins 持续交付
Jenkins Pipeline 流水线 - Parameters 参数化构建
Jenkins Pipeline 流水线 - Parameters 参数化构建
1124 0