From f66f7ea9499d570d8b45c4f9510dd3ef7071c7be Mon Sep 17 00:00:00 2001 From: Jesse Houldsworth Date: Fri, 14 Mar 2025 10:23:12 -0700 Subject: [PATCH] fixing mvn --- .github/workflows/ci-pipeline.yml | 58 +++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 13158697a..00958274b 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -1,27 +1,34 @@ -name: CI Pipeline with JFrog Artifactory +name: Build and Publish with JFrog Artifactory on: push: - branches: - - main + branches: [ "main" ] pull_request: - branches: - - main + branches: [ "main" ] jobs: build: runs-on: ubuntu-latest steps: - - name: Checkout repository + ################################################################ + # 1) Check out your code + ################################################################ + - name: Checkout uses: actions/checkout@v3 + ################################################################ + # 2) Set up Java + ################################################################ - name: Set up JDK 17 uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '17' + ################################################################ + # 3) Install & configure JFrog CLI + ################################################################ - name: Install JFrog CLI run: | curl -fL https://getcli.jfrog.io | bash @@ -32,10 +39,14 @@ jobs: run: | jfrog config add my-artifactory \ --artifactory-url=https://trialt0zppb.jfrog.io/artifactory \ - --user=${{ secrets.ARTIFACTORY_USERNAME }} \ - --password=${{ secrets.ARTIFACTORY_IDENTITY_TOKEN }} \ + --user="${{ secrets.ARTIFACTORY_USERNAME }}" \ + --password="${{ secrets.ARTIFACTORY_IDENTITY_TOKEN }}" \ --interactive=false + ################################################################ + # 4) Configure Maven to Use Artifactory + # (jfrog rt mvnc sets up the Maven resolver & deploy repos) + ################################################################ - name: Configure JFrog CLI for Maven run: | jfrog rt mvnc \ @@ -46,28 +57,37 @@ jobs: --repo-deploy-releases=maven-libs-release-local \ --repo-deploy-snapshots=maven-libs-snapshot-local - - name: Debug Maven Settings - run: mvn help:effective-settings + ################################################################ + # 5) Clear the local .m2 cache to avoid leftover references + ################################################################ + - name: Clear local Maven cache + run: rm -rf ~/.m2/repository - - name: Compile and Package the Application - run: mvn clean package -DskipTests - - - name: Publish Maven Artifact to JFrog Artifactory + ################################################################ + # 6) Maven build & publish artifact via JFrog CLI with build info + ################################################################ + - name: Build & Publish Maven Artifact run: | jfrog rt mvn clean install \ --build-name=spring-petclinic \ - --build-number=${{ github.run_id }} + --build-number="${{ github.run_id }}" + ################################################################ + # 7) Build and push Docker image with JFrog CLI (no 'docker push') + ################################################################ - name: Build Docker Image run: | docker build -t trialt0zppb.jfrog.io/onboarding-docker-local/spring-petclinic:${{ github.run_id }} . - - name: Push Docker Image to JFrog Artifactory using JFrog CLI + - name: Push Docker Image to Artifactory run: | jfrog rt docker-push trialt0zppb.jfrog.io/onboarding-docker-local/spring-petclinic:${{ github.run_id }} onboarding-docker-local \ --build-name=spring-petclinic \ - --build-number=${{ github.run_id }} + --build-number="${{ github.run_id }}" - - name: Publish Build Info to JFrog Artifactory + ################################################################ + # 8) Publish the Build Info to Artifactory for full traceability + ################################################################ + - name: Publish Build Info run: | - jfrog rt build-publish spring-petclinic ${{ github.run_id }} + jfrog rt build-publish spring-petclinic "${{ github.run_id }}"