Jenkins Pipeline: How to configure Polling ignores commits in certain paths?

58 Views Asked by At

we are currently setting up CI/CD Pipelines for our microfrontend projects. These projects are in one repository. We want to setup a pipeline for every project. Our plan is to use the Polling ignores commits in certain paths setting from the git Plugin to prevent building the pipeline when commits are pushed outside of the project folder or when the deployment file is changed. The deployment file will be changed an pushed to the repo in a pipeline step. Now the pipeline is in a loop because our settings doesnt seem to work. Did we configuere somethink wrong?

These are the pipeline settings:

Build triggers

Pipeline settings 1/2

Pipeline settings 2/2

And this is the Jenkinsfile:

pipeline {
  agent {
    kubernetes {
      yaml '''
        // kubernetes yaml
        '''
    }
  }
  stages {
        stage('Checkout from SCM') {
          steps {
            container('node') {
              git branch: '[BRANCH]', credentialsId: '[CREDENTIAL_ID]', url: '[URL]'
            }
          }
        }
        stage('Build docker-image and push to registry') {
            steps {
                container('node') {
                  dir("frontend/shell") {
                    withDockerRegistry([credentialsId: '[CREDENTIAL_ID]', url: "[URL]"]) {
                      // build steps
                    }
                   }
                }
            }
        }
        stage('Remove Recent Image from Node') {
          steps {
            container('node') {
              sh "docker rmi [IMAGE_NAME]:v1.2.1.${env.BUILD_NUMBER}"
            }
          }
        }
        stage('Edit deploymentDev.yaml') {
          steps {
            container('node') {
              script {
                def yamlFilePath = 'frontend/shell/deployment/deploymentDev.yaml'
                def newImage = "[IMAGE_NAME]:v1.2.1.${env.BUILD_NUMBER}"
                sh "sed -i 's|image:.*|image: ${newImage}|' ${yamlFilePath}"
              }
            }
          }
        }
        stage ('Deploy to Test-Cluster') {
          steps {
            container('node') {
              dir("frontend/shell/deployment") {
                sh 'kubectl apply -f deploymentDev.yaml'
                }
              }
            }
          }
        stage('Commit Changes to deployment file') {
          steps {
            container('node') {
              withCredentials([usernamePassword(credentialsId: '[CREDENTIAL_ID]', passwordVariable: 'password', usernameVariable: 'username')]) {
                  // commit and push
              }
            }
          }
        }
  }
  post {
        // post steps
    }
}```


We checked the documentation of the git plugin and think this configuration should work.
0

There are 0 best solutions below