0

In the pipeline run, I have use taskRunSpecs to set the service account, the git clone is working fine, however with the GCP publish with the maven library failed with error message as

Failed to publish publication 'maven' to repository 'maven'
2023-07-29T12:17:51.116212588Z    > Could not PUT 'https://australia-southeast2-maven.pkg.dev/fetebird-392007/common/fete/bird/common/0.0.0/common-0.0.0.jar'. Received status code 401 from server: Unauthorized
2023-07-29T12:17:51.116231838Z 

pipeline.yaml

apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: ft-common
  namespace: fetebird-tekton
spec:
  params:
    - name: repo-url
      type: string
    - name : GRADLE_IMAGE
      type: string
  workspaces:
    - name: shared-data
  tasks:
    - name: git-clone
      taskRef:
        name: git-clone
      workspaces:
        - name: output
          workspace: shared-data
      params:
        - name: url
          value: "$(params.repo-url)"
        - name: deleteExisting
          value: "true"
    - name: clean-build-publish
      taskRef:
        name: gradle
      runAfter: ["git-clone"]  # Wait until the clone is done before building the java project.
      workspaces:
        - name: source
          workspace: shared-data
      params:
        - name: TASKS
          value:
            - clean
            - build
            - test
            - publish
        - name: GRADLE_IMAGE
          value: "$(params.GRADLE_IMAGE)"

pipeline-run.yaml

apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  name: ft-common-run
  namespace: fetebird-tekton
spec:
  pipelineRef:
    name: ft-common
  podTemplate:
    securityContext:
      fsGroup: 65532
  workspaces:
    - name: shared-data
      persistentVolumeClaim:
        claimName: fetebird-common-pvc
  params:
    - name: repo-url
      value: git@bitbucket.org:anandjaisy/common.git
    - name: GRADLE_IMAGE
      value: docker.io/library/gradle:jdk17-alpine@sha256:e80d3108c319eaeef966eefdfd075fdaa44201c8fb6730532a16555426c61dbd
  taskRunSpecs:
    - pipelineTaskName: git-clone
      taskServiceAccountName: git-service-account
    - pipelineTaskName: git-clone
      taskServiceAccountName: gcp-service-account

Build.Gradle

plugins {
    id 'java-library'
    id 'maven-publish'
    id "com.google.cloud.artifactregistry.gradle-plugin" version "2.2.1"
}
repositories {
    mavenLocal()
    mavenCentral()
}

publishing {
    publications {
        maven(MavenPublication) {
            groupId = GROUP
            artifactId = 'common'
            version = VERSION
            from components.java
        }
    }
    repositories {
        maven {
            def releaseURL = "artifactregistry://${LOCATION}-maven.pkg.dev/${PROJECT}/${REPOSITORY}"
            url releaseURL
        }
    }
}

Authentication is keep getting failed. I am doing in local env with minikube

enter image description here

San Jaisy
  • 15,327
  • 34
  • 171
  • 290

0 Answers0