我目前正在尝试推送 Golang 应用程序的 docker 映像(用于部署目的)和构建工件(用于跟踪目的),这是我当前的管道。
name: Build and Push Docker Image and Go Artifacts
on:
push:
branches:
- jfrog-dev # Your specified branch
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the code from the repository
- name: Checkout code
uses: actions/checkout@v2
# Step 2: Verify JFROG_URL and USER
- name: Verify credentials
run: |
echo "JFROG_URL is ${JFROG_URL}"
echo "JFROG_USER is ${JFROG_USER}"
# Step 3: Set up Go environment
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: '1.23'
# Step 4: Install dependencies and build Go binary
- name: Install dependencies and build Go binary
run: |
go mod tidy
go build -o mit-sphere ./cmd/main.go
# Step 5: Install JFrog CLI
- name: Install JFrog CLI
run: |
curl -fL https://getcli.jfrog.io | sh
sudo mv jfrog /usr/local/bin/
echo "JFrog CLI version:"
jfrog --version
# Step 6: Log in to JFrog Artifactory for Docker
- name: Log in to JFrog Artifactory for Docker
run: |
echo "${{ secrets.JFROG_PASSWORD }}" | docker login mani.jfrog.io -u "${{ secrets.JFROG_USER }}" --password-stdin
# Step 7: Build and tag Docker image
- name: Build and tag Docker image
run: |
docker build . -t mit-sphere:latest
docker tag mit-sphere:latest mani.jfrog.io/mani1234-maniit/mit-sphere:latest
# Step 8: Push Docker image to JFrog Artifactory
- name: Push Docker image to JFrog Artifactory
run: |
docker push mani.jfrog.io/mani1234-maniit/mit-sphere:latest
# Step 9: Configure JFrog CLI with username and password
- name: Configure JFrog CLI
run: |
jfrog config add --url "${{ secrets.JFROG_URL }}" --user "${{ secrets.JFROG_USER }}" --password "${{ secrets.JFROG_PASSWORD }}"
# Step 10: Deploy Go artifact to JFrog Artifactory
- name: Deploy Go artifact to JFrog Artifactory
run: |
echo "Publishing Go package to JFrog Artifactory"
jfrog gp mit-sphere-new-go 1 --server-id rt-server # 1 - stands for version number
推送代码并触发构建后,我不断收到以下错误
配置 JFrog CLI
0s
Run jfrog config add --url "***" --user "***" --password "***"
jfrog config add --url "***" --user "***" --password "***"
shell: /usr/bin/bash -e {0}
env:
GOROOT: /opt/hostedtoolcache/go/1.23.1/x64
Error: [Error] The following error was received while trying to encrypt your password: Artifactory response: 404
Error: Process completed with exit code 1.
我已将 URL、用户和密码存储为 GitHub 机密。 另外,我必须使用 MFA 登录控制台(不确定这是否是一个拦截器)
我无法完成配置 CLI 步骤,并且想知道我到底哪里出了问题。任何帮助将不胜感激。谢谢!
jf config add
命令中有2个URL:
这是 JFrog Artifactory 网址。 (例如:
https://mani.jfrog.io/artifactory
)
jfrog config add artifactory --artifactory-url "${{ secrets.JFROG_URL }}" --user "${{secrets.JFROG_USER }}" --password "${{ secrets.JFROG_PASSWORD }}"
这是 JFrog 平台网址。 (例如:
https://mani.jfrog.io
)
jfrog config add artifactory --url "https://mani.jfrog.io" --user "${{secrets.JFROG_USER }}" --password "${{ secrets.JFROG_PASSWORD }}"
您也可以设置
--interactive=false
以确保,即使 $CI
不正确。