Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-68186

Problem Pod Yaml Kubernetes Plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • kubernetes-plugin
    • None
    • AKS: 1.22.6
      Docker image: jenkins/jenkins:2.319.3 (Helm proyect)
      Plugins:
      - kubernetes:1.31.1
      - workflow-job:2.42
      - workflow-cps:2.94.1

      Good Days!

      I try to export all pod templates in one repository but it's impossible. 

      I think that the Kubernetes plugin read only the files with jenkinsfiles. I can't change the directory.

       

      My Problem:

      ERROR: /var/jenkins_home/workspace/BACK-XXXX-BE-CICD-DEV/podtemplates/buildandeploy.yaml references a file that is not inside /var/jenkins_home/workspace/BACK-XXXX-BE-CICD-DEV@script/476260e2b89c89919685063f5e266301fa329b683e3e2dac05f5e7bd2c517b4e

       

      My jenkinfile:

      pipeline {

      // VARIABLES TO ASSIGN
      environment

      { BRANCH_NAME_BACK = "develop" GIT_CREDENTIAL_ID = "mycredential" GIT_URL_BACK = "xxxx" GIT_URL_CONFIG = "XXXX" IMAGE_NAME_BACK = "example-img" image_version = "develop-vtest" }

      agent any
      stages {
      stage('Checkout pod templates') {
      steps {
      dir ('podtemplates')

      { git ( branch: "develop", credentialsId: "$GIT_CREDENTIAL_ID", url: "https://example/k8s-pod-templates.git") }

      }
      }
      stage('Build Phase') {
      agent {
      kubernetes

      { yamlFile "$WORKSPACE/podtemplates/buildandeploy.yaml" }

      }
      steps {
      //Backend
      // Pull Resources
      echo 'check out from gitlab Backend'
      dir ('infra')

      { git ( branch: "$BRANCH_NAME_BACK", credentialsId: "$GIT_CREDENTIAL_ID", url: "$GIT_URL_BACK") }

      // Build as Image
      echo 'Build Backend'
      container('kaniko') {
      script {
      dir ('infra') {
      sh '''
      /kaniko/executor --context `pwd` \
      --destination=registry.azurecr.io/${IMAGE_NAME_BACK}:${image_version}
      '''
      }
      }
      }
      }
      }
      }
      }

      I change the directory for yamlFile, but it isn't working, It always searches in BACK-XXXX-BE-CICD-DEV@script but when I do "git clone", the directory is BACK-XXXX-BE-CICD-DEV.

      Please, Are there some way for this?

      I have a lot of pipelines and I need only the same pod template.

      Thank you very much.
      Regards.

       

       

       

            Unassigned Unassigned
            davidse David San Segundo Gutiérrez
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: