Doker安装
- 创建一个data目录用于数据持久化
mkdir data chmod -R 777 ./data
- 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
- 访问 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(); } }
上传应用
- 生成配置生成Artifactory仓库上传配置文件,选择仓库,点击‘Set Me Up’查看部署配置