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’查看部署配置
相关文章
|
3天前
|
Java 程序员 Docker
爱了!Alibaba技术官甩出的SpringCloud笔记,GitHub已标星81.6k
阿里巴巴,作为国内互联网公司的Top,算是业界的标杆,有阿里背景的程序员,也更具有权威性。作为程序员,都清楚阿里对于员工要求有多高,技术人员掌握的技术水平更是望尘莫及。所以,大厂程序员的很多经验也都值得我们借鉴和学习,在一定程度上确实能够帮助我们“走捷径”。
|
Kubernetes 关系型数据库 MySQL
制品库 Jfrog Artifactory 搭建私服
JFrog Artifactory 功能最强大的二进制制品仓库。在 Google、Apple、思科、甲骨文、华为、腾讯等众多世界500强公司中都有大规模使用,在二进制软件制品管理领域处于绝对领先地位。与其他服务不同,JJFrog Artifactory 在版本发行上分类较多且杂。
1216 0
制品库 Jfrog Artifactory 搭建私服
|
Java Maven
最快的 maven repository--阿里镜像仓库
国内速度超快的maven repository
157555 0
|
6月前
|
Java 数据安全/隐私保护
|
9月前
|
Devops 数据安全/隐私保护 Docker
gitlab--集成 jfrog artifactory 制品库
gitlab--集成 jfrog artifactory 制品库
|
XML Java Maven
你入职的时候一定要问领导要的maven私服配置文件,它是什么?Nexus入门使用指南
你入职的时候一定要问领导要的maven私服配置文件,它是什么?Nexus入门使用指南
你入职的时候一定要问领导要的maven私服配置文件,它是什么?Nexus入门使用指南
|
ARouter 算法 Java
来开源吧!发布开源组件到 MavenCentral 仓库超详细攻略
来开源吧!发布开源组件到 MavenCentral 仓库超详细攻略
722 0
来开源吧!发布开源组件到 MavenCentral 仓库超详细攻略
|
Java Maven 数据安全/隐私保护
发布制品到 Jfrog Artifactory
本篇内容记录了如何将制品发布到 Jfrog Artifactory的相关操作。
363 0
发布制品到 Jfrog Artifactory
|
缓存 Oracle 安全
项目使用 Jfrog Artifactory 制品库
本篇内容记录了如何使用Jfrog Artifactory 制品库。
867 0
项目使用 Jfrog Artifactory 制品库
|
Java Linux API
给技术经理找了几款Docker开源镜像仓库,为什么经理选中了Sonatype Nexus(上)
给技术经理找了几款Docker开源镜像仓库,为什么经理选中了Sonatype Nexus(上)
964 0
给技术经理找了几款Docker开源镜像仓库,为什么经理选中了Sonatype Nexus(上)