Go——连接 JFrog Artifactory 简单测试

Posted Starzkg

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Go——连接 JFrog Artifactory 简单测试相关的知识,希望对你有一定的参考价值。

源代码:https://gitee.com/shentuzhigang/mini-project/blob/master/jfrog-client-demo/artifactory/artifactory_test.go

官方SDK:http://github.com/jfrog/jfrog-client-go

解决方案

package artifactory

import (
	"fmt"
	"github.com/jfrog/jfrog-client-go/artifactory"
	"github.com/jfrog/jfrog-client-go/artifactory/auth"
	"github.com/jfrog/jfrog-client-go/config"
	"github.com/jfrog/jfrog-client-go/utils/log"
	"os"
	"testing"
	"time"
)

func TestConnect(t *testing.T) {
	var file *os.File
	log.SetLogger(log.NewLogger(log.INFO, file))
	rtDetails := auth.NewArtifactoryDetails()
	rtDetails.SetUrl("http://192.168.0.112:8081/artifactory/")
	rtDetails.SetUser("admin")
	rtDetails.SetPassword("123456")

	serviceConfig, err := config.NewConfigBuilder().
		SetServiceDetails(rtDetails).
		// Optionally overwrite the default HTTP timeout, which is set to 30 seconds.
		SetHttpTimeout(180 * time.Second).
		// Optionally overwrite the default HTTP retries, which is set to 3.
		SetHttpRetries(8).
		Build()
	if err != nil {
		fmt.Println(err)
	}
	rtManager, err := artifactory.New(serviceConfig)

	ping, err := rtManager.Ping()
	if err != nil {
		return
	}
	fmt.Printf("artifactory connect is %s\\n", string(ping))
}

参考文章

以上是关于Go——连接 JFrog Artifactory 简单测试的主要内容,如果未能解决你的问题,请参考以下文章

发布制品到 Jfrog Artifactory

jfrog artifactory docker 安装试用

如何在云上创建自己的 Artifactory,例如 AWS 的 Codeartifact、Jfrog 的 Artifactory

CentOS 8安装JFrog Artifactory社区版解决方案

jfrog artifactory jenkins pipeline 集成

搭建私有Jfrog artifactory仓库并上传Android Library