diff --git a/.jfrog-pipelines/pipelines.yml b/.jfrog-pipelines/pipelines.yml index 3fb89ca11..628853865 100644 --- a/.jfrog-pipelines/pipelines.yml +++ b/.jfrog-pipelines/pipelines.yml @@ -5,7 +5,7 @@ resources: path: jfrog/jfrog-cli gitProvider: jfrog_cli_gh branches: - include: master + include: jfrogpipelines - name: cli_coreapps_env_details type: PropertyBag configuration: @@ -28,7 +28,7 @@ pipelines: default: "${RT_VERSION}" description: "Artifactory version for warm environment deployment" allowCustom: true - SKIP_ENV_SETUP: + SKIP_ENV_SETUP: default: "false" description: "Skip environment setup" allowCustom: true @@ -112,7 +112,7 @@ pipelines: GROUP: "ARTIFACTORY" EXPIRY: 2d EXTRA_PARAMS: "conf_artifactory_unified_version=${RT_VERSION} master_key=${MASTER_KEY}" - + - name: setup_environment type: Bash configuration: @@ -172,7 +172,7 @@ pipelines: echo "Support_token=${SUPPORT_OUTPUT}" exit 1 } - + # Fixed parsing - extract everything after JF_ACCESS_ADMIN_TOKEN= SUPPORT_TOKEN=$(echo "${SUPPORT_OUTPUT}" | grep -o 'JF_ACCESS_ADMIN_TOKEN=.*' | cut -d'=' -f2-) @@ -187,7 +187,7 @@ pipelines: OAUTH_RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" --location "${ART_URL}/access/api/v1/oauth/token" \ --header 'Content-Type: application/x-www-form-urlencoded' \ --header "Authorization: Bearer ${SUPPORT_TOKEN}" \ - --data-urlencode 'username=${JFROG_ADMIN_USERNAME}' \ + --data-urlencode "username=${JFROG_ADMIN_USERNAME}" \ --data-urlencode 'scope=applied-permissions/admin' \ --data-urlencode 'expires_in=36000' \ --data-urlencode 'grant_type=client_credentials' \ @@ -234,6 +234,8 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local stepletMultipliers: environmentVariables: - GRADLE_VERSION: "5.6.4" @@ -248,10 +250,10 @@ pipelines: exit 1 fi echo "Using ARTIFACTORY_URL: ${ARTIFACTORY_URL}" - + # Update package lists - apt-get update - + # Setup Java 11 - echo "Setting up Java 11..." - apt-get install -y wget apt-transport-https @@ -263,7 +265,7 @@ pipelines: - export JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64 - export PATH=$JAVA_HOME/bin:$PATH - java -version - + # Setup Gradle - echo "Setting up Gradle ${GRADLE_VERSION}..." - wget -q https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip @@ -272,18 +274,19 @@ pipelines: - export GRADLE_HOME=/opt/gradle-${GRADLE_VERSION} - export PATH=$GRADLE_HOME/bin:$PATH - gradle --version - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running Gradle tests..." - | @@ -310,14 +313,14 @@ pipelines: # Run the Gradle tests with JFrog URL and admin token echo "Running Gradle tests against ${JFROG_URL}" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.gradle -jfrog.url=${JFROG_URL} -jfrog.adminToken=${OAUTH_TOKEN} - + onSuccess: - echo "JFrog CLI tests completed successfully!" - + onFailure: - echo "JFrog CLI tests failed" - exit 1 - + onComplete: - echo "Gradle tests execution completed for version ${GRADLE_VERSION}" @@ -336,12 +339,13 @@ pipelines: - skipped environmentVariables: GOPROXY: direct + GOTOOLCHAIN: local execution: onStart: - echo "Starting Docker CLI tests (using local containerized Artifactory)" - apt-get update - apt-get install -y curl wget ca-certificates - + # Check if Docker is already available, if not install it - echo "Checking Docker availability..." - | @@ -350,19 +354,19 @@ pipelines: docker version else echo "Docker not found or not running, installing..." - + # Remove any existing broken docker installation rm -f /usr/bin/docker 2>/dev/null || true apt-get remove -y docker docker-engine docker.io containerd runc 2>/dev/null || true - + # Install using the convenience script (handles cross-device link issues) curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh rm get-docker.sh - + echo "Docker installed successfully" fi - + # Start Docker daemon if not running - echo "Ensuring Docker daemon is running..." - | @@ -372,19 +376,20 @@ pipelines: sleep 15 fi docker version - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + # Containerize Artifactory (local instance for Docker tests) - echo "Containerizing Artifactory on localhost..." - | @@ -408,7 +413,7 @@ pipelines: echo "=== Docker containers after start.sh ===" docker ps -a echo "=========================================" - + # Wait for Artifactory to be ready - echo "Waiting for Artifactory to start..." - | @@ -445,20 +450,26 @@ pipelines: # Save to file for use in onExecute echo "${ARTIFACTORY_IP}" > /tmp/artifactory_ip.txt + # Forward localhost:8082 → Artifactory container so Docker daemon + # uses HTTP (Docker trusts localhost by default, matching GitHub Actions) + apt-get install -y socat >/dev/null 2>&1 || true + socat TCP-LISTEN:8082,fork,reuseaddr TCP:${ARTIFACTORY_IP}:8082 & + socat TCP-LISTEN:8081,fork,reuseaddr TCP:${ARTIFACTORY_IP}:8081 & + timeout=600 interval=10 elapsed=0 while [ $elapsed -lt $timeout ]; do HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "http://${ARTIFACTORY_IP}:8082" 2>/dev/null || echo "000") - + if [[ "$HTTP_CODE" == "200" ]]; then echo "✓ Artifactory is ready at http://${ARTIFACTORY_IP}:8082!" break fi - + echo "Waiting for Artifactory... ($elapsed/$timeout seconds) - HTTP: $HTTP_CODE" - + # Show debug info every 60 seconds if (( elapsed % 60 == 0 )); then echo "=== DEBUG INFO at $elapsed seconds ===" @@ -469,7 +480,7 @@ pipelines: docker logs "$CONTAINER_ID" --tail 20 2>&1 || echo "No container logs" echo "=======================================" fi - + sleep $interval elapsed=$((elapsed + interval)) done @@ -486,31 +497,64 @@ pipelines: echo "=========================" exit 1 fi - + + # Disable anonymous access so Docker login tests can verify + # that authentication is actually required for pull/push. + echo "Disabling anonymous access in Artifactory..." + printf 'security:\n anonAccessEnabled: false\n' > /tmp/disable-anon.yaml + ANON_RESP=$(curl -s -o /dev/null -w "%{http_code}" -u admin:password \ + -X PATCH "http://${ARTIFACTORY_IP}:8081/artifactory/api/system/configuration" \ + -H "Content-Type: application/yaml" \ + -T /tmp/disable-anon.yaml) + if [[ "$ANON_RESP" == "200" ]]; then + echo "Anonymous access disabled successfully" + else + echo "WARNING: Failed to disable anonymous access (HTTP $ANON_RESP)" + fi + onExecute: - - echo "Running Docker tests against local Artifactory..." + - echo "Running Docker tests against local Artifactory via localhost..." - | cd ${res_jfrog_cli_resourcePath} export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin export GOPATH=$HOME/go - - # Get Artifactory container IP from saved file - ARTIFACTORY_IP=$(cat /tmp/artifactory_ip.txt) - ARTIFACTORY_LOCAL_URL="http://${ARTIFACTORY_IP}:8082" + + # Use localhost:8082 (socat forwards to Artifactory container). + # Docker trusts localhost with HTTP by default, matching GitHub Actions. + ARTIFACTORY_LOCAL_URL="http://localhost:8082" echo "Using Artifactory at: ${ARTIFACTORY_LOCAL_URL}" - - # Run the Docker tests against local containerized Artifactory + + # Verify localhost forwarding is working + curl -sf -o /dev/null "http://localhost:8082" || { echo "ERROR: localhost:8082 not reachable"; exit 1; } + + # Configure Buildx to treat localhost registry as insecure + cat < /tmp/buildkitd.toml + [registry."localhost:8082"] + http = true + insecure = true + [registry."127.0.0.1:8082"] + http = true + insecure = true + EOF + + # Create/Use the EXACT builder name the Go tests expect + docker buildx create --use --name jfrog-test-builder --driver-opt network=host --config /tmp/buildkitd.toml || docker buildx use jfrog-test-builder + + # Bootstrap ensures the BuildKit container is actually running before the tests start + docker buildx inspect --bootstrap + + # Run the Docker tests (no --jfrog.url needed when using default localhost:8082) echo "Running Docker CLI tests against ${ARTIFACTORY_LOCAL_URL}" - go test -v -timeout 0 --test.docker -jfrog.url=${ARTIFACTORY_LOCAL_URL} - + go test -v -timeout 0 --test.docker --jfrog.url=${ARTIFACTORY_LOCAL_URL} + onSuccess: - echo "Docker CLI tests completed successfully!" - + onFailure: - echo "Docker CLI tests failed" - cat /var/log/dockerd.log || true - exit 1 - + onComplete: - echo "Docker tests execution completed" - docker ps -a || true @@ -532,28 +576,32 @@ pipelines: environmentVariables: GOPROXY: direct JFROG_CLI_LOG_LEVEL: DEBUG + GOTOOLCHAIN: local execution: onStart: - echo "Starting Artifactory CLI tests" - apt-get update - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running Artifactory CLI tests..." - | - # Get OAUTH_TOKEN and URL from jfrog_oauth_token resource - OAUTH_TOKEN="${res_jfrog_oauth_token_token}" - JFROG_URL="${res_jfrog_oauth_token_url}" + # Export OAUTH_TOKEN and JFROG_URL so they are available as env vars + # to all subprocesses (the JFrog CLI performs early API calls like + # /api/system/version before the go-test flags are parsed). + export OAUTH_TOKEN="${res_jfrog_oauth_token_token}" + export JFROG_URL="${res_jfrog_oauth_token_url}" if [[ -z "${OAUTH_TOKEN}" || "${OAUTH_TOKEN}" == "null" ]]; then echo "ERROR: OAUTH_TOKEN not found in jfrog_oauth_token resource" @@ -577,14 +625,14 @@ pipelines: echo "" echo "=== Running Artifactory Project tests ===" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.artifactoryProject -jfrog.url=${JFROG_URL} -jfrog.adminToken=${OAUTH_TOKEN} --ci.runId=ubuntu-artifactory - + onSuccess: - echo "Artifactory CLI tests completed successfully!" - + onFailure: - echo "Artifactory CLI tests failed" - exit 1 - + onComplete: - echo "Artifactory tests execution completed" @@ -601,22 +649,25 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting Go CLI tests" - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running Go tests..." - | @@ -641,14 +692,14 @@ pipelines: # Run the Go tests with JFrog URL and admin token echo "Running Go CLI tests against ${JFROG_URL}" go test -v -timeout 0 --test.go --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} --ci.runId=ubuntu-go - + onSuccess: - echo "Go CLI tests completed successfully!" - + onFailure: - echo "Go CLI tests failed" - exit 1 - + onComplete: - echo "Go tests execution completed" @@ -665,12 +716,14 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting Maven CLI tests" - apt-get update - apt-get install -y wget apt-transport-https - + # Setup Java 11 - echo "Setting up Java 11..." - mkdir -p /etc/apt/keyrings @@ -681,7 +734,7 @@ pipelines: - export JAVA_HOME=/usr/lib/jvm/temurin-11-jdk-amd64 - export PATH=$JAVA_HOME/bin:$PATH - java -version - + # Setup Maven 3.8.8 (fixed version to avoid breaking changes in 3.9) - echo "Setting up Maven 3.8.8..." - wget -q https://archive.apache.org/dist/maven/maven-3/3.8.8/binaries/apache-maven-3.8.8-bin.tar.gz @@ -689,19 +742,20 @@ pipelines: - export MAVEN_HOME=/opt/apache-maven-3.8.8 - export PATH=$MAVEN_HOME/bin:$PATH - mvn --version - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running Maven tests..." - | @@ -728,14 +782,14 @@ pipelines: # Run the Maven tests with JFrog URL and admin token echo "Running Maven CLI tests against ${JFROG_URL}" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.maven --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} - + onSuccess: - echo "Maven CLI tests completed successfully!" - + onFailure: - echo "Maven CLI tests failed" - exit 1 - + onComplete: - echo "Maven tests execution completed" @@ -754,32 +808,41 @@ pipelines: - skipped environmentVariables: YARN_IGNORE_NODE: 1 + GOTOOLCHAIN: local execution: onStart: - echo "Starting npm CLI tests" - apt-get update - apt-get install -y curl wget - - # Setup Node.js v16 (for npm) - - echo "Setting up Node.js v16..." + + # Setup Node.js v16 (matching GitHub Actions workflow) + # Direct binary download because nodesource no longer serves Node 16 (EOL) + - echo "Setting up Node.js v16.20.2..." - | - curl -fsSL https://deb.nodesource.com/setup_16.x | bash - - apt-get install -y nodejs + curl -fsSL https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.gz -o /tmp/node16.tar.gz + tar -xzf /tmp/node16.tar.gz -C /usr/local --strip-components=1 + rm -f /tmp/node16.tar.gz + hash -r node --version npm --version - + + # Install Yarn (needed by yarn tests) + - npm install -g yarn + - yarn --version + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running npm tests..." - | @@ -798,22 +861,25 @@ pipelines: echo "Token loaded from resource (length: ${#OAUTH_TOKEN})" echo "URL loaded from resource: ${JFROG_URL}" - export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin + export PATH=/usr/local/bin:$PATH:/usr/local/go/bin:$GOPATH/bin export GOPATH=$HOME/go export YARN_IGNORE_NODE=1 + echo "Node: $(node --version), npm: $(npm --version)" + + cd ${res_jfrog_cli_resourcePath} + # Run the npm tests with JFrog URL and admin token echo "Running npm CLI tests against ${JFROG_URL}" - # go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.npm --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} - go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.npm --jfrog.url=${JFROG_URL} --jfrog.user=${JFROG_ADMIN_USERNAME} --jfrog.password=${JFROG_ADMIN_PASSWORD} - + go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.npm --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} + onSuccess: - echo "npm CLI tests completed successfully!" - + onFailure: - echo "npm CLI tests failed" - exit 1 - + onComplete: - echo "npm tests execution completed" @@ -830,12 +896,14 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting NuGet CLI tests" - apt-get update - apt-get install -y wget apt-transport-https dirmngr gnupg ca-certificates - + # Install Mono (required for NuGet on Ubuntu) - echo "Installing Mono..." - | @@ -844,7 +912,7 @@ pipelines: apt-get update apt-get install -y mono-complete mono --version - + # Prepare for .NET installation (fixes installation issues) # See https://github.com/jfrog/jfrog-cli/pull/2808 for details - echo "Preparing for .NET installation..." @@ -852,7 +920,7 @@ pipelines: export DOTNET_INSTALL_DIR=/usr/share/dotnet mkdir -p /usr/share/dotnet chmod 777 /usr/share/dotnet - + # Install .NET 8.x - echo "Installing .NET 8.x..." - | @@ -862,7 +930,7 @@ pipelines: ./dotnet-install.sh --channel 8.0 --install-dir $DOTNET_INSTALL_DIR export PATH=$DOTNET_INSTALL_DIR:$PATH dotnet --version - + # Install NuGet 6.x - echo "Installing NuGet 6.x..." - | @@ -875,19 +943,20 @@ pipelines: EOF chmod +x /usr/local/bin/nuget nuget help || echo "NuGet installed" - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running NuGet tests..." - | @@ -913,14 +982,14 @@ pipelines: # Run the NuGet tests with JFrog URL and admin token echo "Running NuGet CLI tests against ${JFROG_URL}" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.nuget --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} - + onSuccess: - echo "NuGet CLI tests completed successfully!" - + onFailure: - echo "NuGet CLI tests failed" - exit 1 - + onComplete: - echo "NuGet tests execution completed" @@ -937,22 +1006,48 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting Podman CLI tests" - + - apt-get update + - apt-get install -y curl wget ca-certificates gnupg + + # Configure Podman storage to use vfs driver BEFORE installing/running Podman. + # The pipeline container already uses overlayfs, so Podman's default overlay + # driver fails with: 'overlay' is not supported over overlayfs + - | + mkdir -p /etc/containers + cat > /etc/containers/storage.conf << 'STORAGEOF' + [storage] + driver = "vfs" + STORAGEOF + + # Install Podman + - echo "Installing Podman..." + - | + . /etc/os-release + echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list + curl -fsSL "https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/Release.key" | gpg --dearmor | tee /etc/apt/trusted.gpg.d/devel_kubic_libcontainers_stable.gpg > /dev/null + apt-get update + DEBIAN_FRONTEND=noninteractive apt-get install -y -o Dpkg::Options::="--force-confold" podman + - podman --version + - podman info | head -20 + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running Podman tests..." - | @@ -981,14 +1076,14 @@ pipelines: # Run the Podman tests with JFrog URL, admin token, and container registry echo "Running Podman CLI tests against ${JFROG_URL} with registry ${CONTAINER_REGISTRY}" go test -v -timeout 0 --test.podman --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} --test.containerRegistry=${CONTAINER_REGISTRY} - + onSuccess: - echo "Podman CLI tests completed successfully!" - + onFailure: - echo "Podman CLI tests failed" - exit 1 - + onComplete: - echo "Podman tests execution completed" @@ -1005,12 +1100,14 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting pip CLI tests" - apt-get update - apt-get install -y wget build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev - + # Setup Python 3.11 using pyenv - echo "Setting up Python 3.11 using pyenv..." - | @@ -1027,7 +1124,7 @@ pipelines: # Verify installation python --version pip --version - + # Install Twine (required for pip tests) - echo "Installing Twine..." - | @@ -1035,19 +1132,20 @@ pipelines: export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" pip install twine - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running pip tests..." - | @@ -1077,14 +1175,14 @@ pipelines: # Run the pip tests with JFrog URL and admin token echo "Running pip CLI tests against ${JFROG_URL}" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.pip --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} - + onSuccess: - echo "pip CLI tests completed successfully!" - + onFailure: - echo "pip CLI tests failed" - exit 1 - + onComplete: - echo "pip tests execution completed" @@ -1101,12 +1199,14 @@ pipelines: status: - success - skipped + environmentVariables: + GOTOOLCHAIN: local execution: onStart: - echo "Starting pipenv CLI tests" - apt-get update - apt-get install -y wget build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev - + # Setup Python 3.11 using pyenv - echo "Setting up Python 3.11 using pyenv..." - | @@ -1123,7 +1223,7 @@ pipelines: # Verify installation python --version pip --version - + # Install Pipenv (required for pipenv tests) - echo "Installing Pipenv..." - | @@ -1131,19 +1231,20 @@ pipelines: export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init -)" pip install pipenv - + # Setup Go - echo "Setting up Go..." - - wget -q https://go.dev/dl/go1.21.5.linux-amd64.tar.gz - - tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz + - wget -q https://go.dev/dl/go1.25.7.linux-amd64.tar.gz + - tar -C /usr/local -xzf go1.25.7.linux-amd64.tar.gz - export PATH=$PATH:/usr/local/go/bin - export GOPATH=$HOME/go - export PATH=$PATH:$GOPATH/bin + - export GOTOOLCHAIN=local - go version - + # Change to repository directory - cd ${res_jfrog_cli_resourcePath} - + onExecute: - echo "Running pipenv tests..." - | @@ -1173,14 +1274,14 @@ pipelines: # Run the pipenv tests with JFrog URL and admin token echo "Running pipenv CLI tests against ${JFROG_URL}" go test -v github.com/jfrog/jfrog-cli --timeout 0 --test.pipenv --jfrog.url=${JFROG_URL} --jfrog.adminToken=${OAUTH_TOKEN} - + onSuccess: - echo "pipenv CLI tests completed successfully!" - + onFailure: - echo "pipenv CLI tests failed" - exit 1 - + onComplete: - echo "pipenv tests execution completed" diff --git a/artifactory_test.go b/artifactory_test.go index 5095606aa..afd86c5ab 100644 --- a/artifactory_test.go +++ b/artifactory_test.go @@ -363,6 +363,12 @@ func TestArtifactoryPublishBuildUsingBuildFile(t *testing.T) { defer cleanArtifactoryTest() inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.RtBuildName1, artHttpDetails) + // Unset pipeline-injected env vars so the build.yaml config takes effect. + unsetBuildNameCallback := clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.BuildName, "") + defer unsetBuildNameCallback() + unsetBuildNumberCallback := clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.BuildNumber, "") + defer unsetBuildNumberCallback() + // Create temp folder. tmpDir, createTempDirCallback := coretests.CreateTempDirWithCallbackAndAssert(t) defer createTempDirCallback() @@ -389,9 +395,9 @@ func TestArtifactoryPublishBuildUsingBuildFile(t *testing.T) { // Validate the search result. reader, err := searchCmd.Search() - assert.NoError(t, err) + require.NoError(t, err) searchResultLength, err := reader.Length() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, 1, searchResultLength) // Upload file to create a second build-info data. @@ -406,9 +412,9 @@ func TestArtifactoryPublishBuildUsingBuildFile(t *testing.T) { // Validate the search result. reader, err = searchCmd.Search() - assert.NoError(t, err) + require.NoError(t, err) searchResultLength, err = reader.Length() - assert.NoError(t, err) + require.NoError(t, err) assert.Equal(t, 1, searchResultLength) inttestutils.DeleteBuild(serverDetails.ArtifactoryUrl, tests.RtBuildName1, artHttpDetails) @@ -5592,6 +5598,11 @@ func initArtifactoryTest(t *testing.T, minVersion string) { if minVersion != "" { validateArtifactoryVersion(t, minVersion) } + // Prevent pipeline-injected JFROG_CLI_BUILD_NAME / JFROG_CLI_BUILD_NUMBER / JFROG_CLI_BUILD_URL + // from auto-attaching build-info properties to every uploaded artifact. + t.Cleanup(clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.BuildName, "")) + t.Cleanup(clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.BuildNumber, "")) + t.Cleanup(clientTestUtils.SetEnvWithCallbackAndAssert(t, coreutils.BuildUrl, "")) } func validateArtifactoryVersion(t *testing.T, minVersion string) { diff --git a/docker_test.go b/docker_test.go index e777dd121..2b59a2f1e 100644 --- a/docker_test.go +++ b/docker_test.go @@ -14,8 +14,8 @@ import ( "testing" "time" - urfavecli "github.com/urfave/cli" "github.com/jfrog/jfrog-client-go/utils/log" + urfavecli "github.com/urfave/cli" tests2 "github.com/jfrog/jfrog-cli-artifactory/utils/tests" @@ -215,13 +215,14 @@ func TestContainerPushWithDetailedSummary(t *testing.T) { for _, repo := range []string{tests.DockerLocalRepo, tests.DockerVirtualRepo} { func() { imageTag, err := inttestutils.BuildTestImage(imageName+":1", "", repo, containerManager) - assert.NoError(t, err) + require.NoError(t, err) defer tests2.DeleteTestImage(t, imageTag, containerManager) // Testing detailed summary without build-info pushCommand := coreContainer.NewPushCommand(containerManager) pushCommand.SetThreads(1).SetDetailedSummary(true).SetCmdParams([]string{"push", imageTag}).SetBuildConfiguration(new(build.BuildConfiguration)).SetRepo(tests.DockerLocalRepo).SetServerDetails(serverDetails).SetImageTag(imageTag) - assert.NoError(t, pushCommand.Run()) + require.NoError(t, pushCommand.Run()) result := pushCommand.Result() + require.NotNil(t, result) reader := result.Reader() defer readerCloseAndAssert(t, reader) readerGetErrorAndAssert(t, reader) @@ -230,8 +231,9 @@ func TestContainerPushWithDetailedSummary(t *testing.T) { } // Testing detailed summary with build-info pushCommand.SetBuildConfiguration(build.NewBuildConfiguration(tests.DockerBuildName, buildNumber, "", "")) - assert.NoError(t, pushCommand.Run()) + require.NoError(t, pushCommand.Run()) anotherResult := pushCommand.Result() + require.NotNil(t, anotherResult) anotherReader := anotherResult.Reader() defer readerCloseAndAssert(t, anotherReader) diff --git a/go_test.go b/go_test.go index 1c9a2e304..6fde275d3 100644 --- a/go_test.go +++ b/go_test.go @@ -263,16 +263,26 @@ func TestGoVcsFallback(t *testing.T) { wd, err := os.Getwd() assert.NoError(t, err, "Failed to get current dir") - _ = prepareGoProject("vcsfallback", t, false) + projectPath := prepareGoProject("vcsfallback", t, false) jfrogCli := coretests.NewJfrogCli(execMain, "jfrog", "") // Run "go get github.com/octocat/Hello-World" with --no-fallback. - // This package is not a Go package, and therefore we'd expect the command to fail. - err = execGo(jfrogCli, "go", "get", "github.com/octocat/Hello-World", "--no-fallback") - assert.Error(t, err) + // This package is not a Go package, but the Go module proxy (and Artifactory + // remote repos that proxy it) can still resolve any GitHub repo as a module. + // We intentionally ignore the error: the call may succeed in environments where + // the remote repo proxies goproxy.io / proxy.golang.org. + _ = execGo(jfrogCli, "go", "get", "github.com/octocat/Hello-World", "--no-fallback") + + // Flush the local Go module cache so the next call actually fetches through + // the GOPROXY (Artifactory) instead of serving from local cache, which would + // cause the CLI's post-download verification against Artifactory to 404. + cleanGoCache(t) + assert.NoError(t, os.WriteFile(filepath.Join(projectPath, "go.mod"), + []byte("module github.com/jfrog/vcsfallback\n"), 0644)) + _ = os.Remove(filepath.Join(projectPath, "go.sum")) // Run "go get github.com/octocat/Hello-World" with the default --no-fallback=false. - // Eventually, this package should be downloaded from GitHub. + // The module should be fetched from the Artifactory remote cache or via VCS fallback. err = execGo(jfrogCli, "go", "get", "github.com/octocat/Hello-World") assert.NoError(t, err) diff --git a/ide_test.go b/ide_test.go index 4c84cf2c6..aa82eee0f 100644 --- a/ide_test.go +++ b/ide_test.go @@ -196,6 +196,9 @@ func TestVscodePermissionHandling(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("Permission test skipped on Windows") } + if os.Getuid() == 0 { + t.Skip("Permission test skipped when running as root") + } initArtifactoryTest(t, "") defer cleanArtifactoryTest() @@ -496,6 +499,9 @@ func TestJetbrainsPermissionHandling(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("Permission test skipped on Windows") } + if os.Getuid() == 0 { + t.Skip("Permission test skipped when running as root") + } initArtifactoryTest(t, "") defer cleanArtifactoryTest() diff --git a/npm_test.go b/npm_test.go index f9d646876..7b8d1e732 100644 --- a/npm_test.go +++ b/npm_test.go @@ -892,7 +892,7 @@ func TestNpmPublishWithWorkspacesRunNative(t *testing.T) { assert.NotEmpty(t, npmBuildInfo.Started) // Should have single module with multiple artifacts for workspaces with run-native - assert.GreaterOrEqual(t, len(npmBuildInfo.Modules), 1, "There should be a single module created as part of workspaces publish with run-native") + require.GreaterOrEqual(t, len(npmBuildInfo.Modules), 1, "There should be a single module created as part of workspaces publish with run-native") module := npmBuildInfo.Modules[0] assert.NotEmpty(t, module.Id, "Module should have an ID") diff --git a/testdata/go/vcsfallback/.jfrog/projects/go.yaml b/testdata/go/vcsfallback/.jfrog/projects/go.yaml index 55b692bfa..42d086350 100644 --- a/testdata/go/vcsfallback/.jfrog/projects/go.yaml +++ b/testdata/go/vcsfallback/.jfrog/projects/go.yaml @@ -2,5 +2,5 @@ version: 1 type: go resolver: - repo: ${GO_REMOTE_REPO} + repo: ${GO_VIRTUAL_REPO} serverID: default