Support polling viewMask filters with wildcards

      For example, we want to list source files in any directory.

      //depot/main/project/....cpp

      //depot/main/project/....h

       

          [JENKINS-45856] support view Mask filters with wildcards

          Joel Brown added a comment -

          Joel Brown added a comment - p4paul polling filters.  This code: https://swarm.workshop.perforce.com/files/guest/perforce_software/p4jenkins/main/src/main/java/org/jenkinsci/plugins/p4/tasks/PollTask.java

          Karl Wirth added a comment -

          Would also be good if we could have nested wildcards. For example:

          //depot/..../bin/...
          

          Karl Wirth added a comment - Would also be good if we could have nested wildcards. For example: //depot/..../bin/...

          Requires map code improvments in P4Java.

          W Basu Perforce added a comment - Requires map code improvments in P4Java.

          Brian Jackson added a comment -

          I'm not clear on how you'd like to implement it with p4java, but I've been using a private fork with this small hack to PollTask.java since July and it meets our needs for a single `...` wildcard embedded within the path (ex. "//depot/path/....java"):

          	boolean isFileInViewMask = false;
          	String p = s.getDepotPathString();
          	for (String maskPath : viewMask.split("\n")) {
          -		if (p.startsWith(maskPath)) {
          +
          +		// If there is a '...' wildcard
          +		String[] maskPathParts = maskPath.split("[.]{3}");
          +		if(maskPathParts.length == 2 && p.startsWith(maskPathParts[0]) && p.endsWith(maskPathParts[1])) {
          +			isFileInViewMask = true;
          +		} else if (p.startsWith(maskPath)) {
           			isFileInViewMask = true;
           		}
          

           

          Brian Jackson added a comment - I'm not clear on how you'd like to implement it with p4java, but I've been using a private fork with this small hack to PollTask.java since July and it meets our needs for a single `...` wildcard embedded within the path (ex. "//depot/path/....java"): boolean isFileInViewMask = false ; String p = s.getDepotPathString(); for ( String maskPath : viewMask.split( "\n" )) { - if (p.startsWith(maskPath)) { + + // If there is a '...' wildcard + String [] maskPathParts = maskPath.split( "[.]{3}" ); + if (maskPathParts.length == 2 && p.startsWith(maskPathParts[0]) && p.endsWith(maskPathParts[1])) { + isFileInViewMask = true ; + } else if (p.startsWith(maskPath)) { isFileInViewMask = true ; }  

          Paul Allen added a comment - - edited

          Hi Brian, thank you for sharing the code snippet.  That would work for most customers and I am tempted to merge that into the code for the time being.   To fully support the Perforce mapping we would need to include exclusionary mappings , overlay mappings , multiple '...' and '*' wild cards, and possibly '%%n' mappings.  The other derived APIs inherit this from the C++ API, but p4java is native and we would need to implement the map code in full.

          Paul Allen added a comment - - edited Hi Brian, thank you for sharing the code snippet.  That would work for most customers and I am tempted to merge that into the code for the time being.   To fully support the Perforce mapping we would need to include exclusionary mappings , overlay mappings , multiple '...' and '*' wild cards, and possibly '%%n' mappings.  The other derived APIs inherit this from the C++ API, but p4java is native and we would need to implement the map code in full.

          Karl Wirth added a comment - - edited

          ++Usage case - Need to exclude changes that include *.inf files. For example not trigger the build if it matches:

          //depot/MyProject/....inf

           

          NOTE FOR DEVELOPERS: Is this now possible with the new map code in P4JAVA?

          Karl Wirth added a comment - - edited ++Usage case - Need to exclude changes that include *.inf files. For example not trigger the build if it matches: //depot/MyProject/....inf   NOTE FOR DEVELOPERS: Is this now possible with the new map code in P4JAVA?

          Karl Wirth added a comment -

          Usage case:  excluding all 32 bit platform changes. Given paths:

           

             //depot/project1/main/NTX86/...

             //depot/project1/main/NTX64/...

             //depot/project1/main/Linux86/...

             //depot/project1/main/Linux64/...

           

          Want to use the filters:

          //depot/project1/main/*86/...

           

          Karl Wirth added a comment - Usage case:  excluding all 32 bit platform changes. Given paths:      //depot/project1/main/NTX86/...    //depot/project1/main/NTX64/...    //depot/project1/main/Linux86/...    //depot/project1/main/Linux64/...   Want to use the filters: //depot/project1/main/*86/...  

          Karl Wirth added a comment -

          Usage case from JENKINS-66195

          following view filer definition:
          //depot/subdirectory-//.../*.txt
          filters out all *.txt files as irrelevant changes (that do not trigger build in jenkins).
          If changelist consists of only "//depot/subdirectory/docs/readme.txt" file, it would not trigger build
          

          Karl Wirth added a comment - Usage case from JENKINS-66195 following view filer definition: //depot/subdirectory-//.../*.txt filters out all *.txt files as irrelevant changes (that do not trigger build in jenkins). If changelist consists of only " //depot/subdirectory/docs/readme.txt" file, it would not trigger build

          Karl Wirth added a comment -

          Start of a potential solution in - JENKINS-66195

          Karl Wirth added a comment - Start of a potential solution in - JENKINS-66195

          Karl Wirth added a comment -

          See proposed code solution in JENKINS-66195

          Karl Wirth added a comment - See proposed code solution in JENKINS-66195

            Unassigned Unassigned
            joel_brown Joel Brown
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated: