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

hudson.plugins.accurev.parsers.xml.ParseHistory.java::parseAll() only get the first version tag for each transaction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • accurev-plugin
    • None

      Version report

      Jenkins and plugins versions report:
       {{Jenkins-Version: 2.138.4
      AccuRev plugin-Version: 0.7.24}} * What Operating System are you using (both controller, and any agents involved in the problem)?

       {{ Red Hat Enterprise Linux Server release 7.9 (Maipo)}}

      Reproduction steps

      • Step 1. Config a Jenkins project to use ‘AccuRev’ as ‘Source Code Management’ (fill out the Accurev configuration per your Accurev settings), and don’t check ‘Delete workspace before build starts’ in ‘Build Environment’ check boxes.
      • Step 2. Build the project. For the first building, all source files will be download to the workspace form Accurev server in Jenkins server.
      • Step 3. Promote some changed files to Accurev steam which is used by the Jenkins project in step 1. Note: the files are needed to be promoted in one ‘Promote’ action.
      • Step 4. Build the project again in Jenkins. You will see the issue! – Jenkins just re-populates one file from Accurev instead of re-populating all files which are promoted in step 3.

      Results

      Assume Jenkins checks out the transactions from AccuRev as below (Please note there are 2 transactions with 3 and 1 version tags respectively):
       <?xml version="1.0" encoding="utf-8"?>
      <AcResponse
          Command="hist"
          TaskId="3849685">
        <transaction
            id="15637416"
            type="promote"
            time="1628646014"
            user="user1">
          <comment>VXX-2440</comment>
          <version
              path="/./CS/Vxx/src/VxxUI/src/MipsMsgParser.h"
              eid="1277637"
              virtual="31721/9"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/9"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>
          <version
              path="/./CS/Vxx/src/VxxUI/src/DbModelErrorLog.cpp"
              eid="1277638"
              virtual="31721/11"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/11"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>
          <version
              path="/./CS/Vxx/src/VxxUI/src/MipsSessions.cpp"
              eid="1277653"
              virtual="31721/28"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/28"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>    
        </transaction>
        <transaction
            id="15636240"
            type="promote"
            time="1628602397"
            user="user2">
          <comment>Bootloader version 1.060</comment>
          <version
              path="/./CS/Vxx/releases/MCB_Bootloader_ENG/3726_ML_BootKinetis_SXX_1.060.zip"
              eid="1680829"
              virtual="31721/1"
              real="31903/1"
              virtualNamedVersion="Vxx_Development/1"
              realNamedVersion="Vxx_Development_user2/1"
              elem_type="binary"
              dir="no">
            <issueNum>97026</issueNum>
          </version>
        </transaction>
        <streams>
          <stream
              id="31721"
              name="Vxx_Development"
              type="normal"/>
        </streams>
      </AcResponse><?xml version="1.0" encoding="utf-8"?>
      <AcResponse
          Command="hist"
          TaskId="3849685">
        <transaction
            id="15637416"
            type="promote"
            time="1628646014"
            user="user1">
          <comment>VXX-2440</comment>
          <version
              path="/./CS/Vxx/src/VxxUI/src/MipsMsgParser.h"
              eid="1277637"
              virtual="31721/9"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/9"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>
          <version
              path="/./CS/Vxx/src/VxxUI/src/DbModelErrorLog.cpp"
              eid="1277638"
              virtual="31721/11"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/11"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>
          <version
              path="/./CS/Vxx/src/VxxUI/src/MipsSessions.cpp"
              eid="1277653"
              virtual="31721/28"
              real="39907/1"
              virtualNamedVersion="Vxx_Development/28"
              realNamedVersion="Vxx_Development_UT_user1/1"
              elem_type="ptext"
              dir="no">
            <issueNum>96970</issueNum>
          </version>    
        </transaction>
        <transaction
            id="15636240"
            type="promote"
            time="1628602397"
            user="user2">
          <comment>Bootloader version 1.060</comment>
          <version
              path="/./CS/Vxx/releases/MCB_Bootloader_ENG/3726_ML_BootKinetis_SXX_1.060.zip"
              eid="1680829"
              virtual="31721/1"
              real="31903/1"
              virtualNamedVersion="Vxx_Development/1"
              realNamedVersion="Vxx_Development_user2/1"
              elem_type="binary"
              dir="no">
            <issueNum>97026</issueNum>
          </version>
        </transaction>
        <streams>
          <stream
              id="31721"
              name="Vxx_Development"
              type="normal"/>
        </streams>
      </AcResponse>

      Expected result:

      Check output file PopulateFiles2056xxxxxxxxxxx.txt, we should get:
      CS/Vxx/src/VxxUI/src/MipsMsgParser.h
      CS/Vxx/src/VxxUI/src/DbModelErrorLog.cpp
      CS/Vxx/src/VxxUI/src/MipsSessions.cpp
      CS/Vxx/releases/MCB_Bootloader_ENG/3726_ML_BootKinetis_SXX_1.060.zip

      Actual result:

      But we only get the first changed file of each transaction:
      CS/Vxx/src/VxxUI/src/MipsMsgParser.h
      CS/Vxx/releases/MCB_Bootloader_ENG/3726_ML_BootKinetis_SXX_1.060.zip

      With a quick check, we believe there is a bug in function parseAll() of file hudson.plugins.accurev.parsers.xml.ParseHistory.java.
      Here is a fix and it works:
         public Boolean parseAll(XmlPullParser parser, List<AccurevTransaction> context) throws IOException, XmlPullParserException {    
          AccurevTransaction resultTransaction = null;
          while (parser.next() != XmlPullParser.END_DOCUMENT) {
            if (parser.getEventType() == XmlPullParser.START_TAG) {
              if ("transaction".equals(parser.getName())) {
                resultTransaction = new AccurevTransaction();
                resultTransaction.setId(parser.getAttributeValue("", "id"));
                resultTransaction.setAction(parser.getAttributeValue("", "type"));
                resultTransaction.setDate(AccurevUtils.convertAccurevTimestamp(parser.getAttributeValue("", "time")));
                resultTransaction.setUser(parser.getAttributeValue("", "user"));
              } else if ("comment".equals(parser.getName()) && resultTransaction != null) {
                resultTransaction.setMsg(parser.nextText());
              } else if ("version".equals(parser.getName()) && resultTransaction != null) {
                String path = parser.getAttributeValue("", "path");
                if (path != null)
                  path = AccurevUtils.cleanAccurevPath(path); 
                resultTransaction.addAffectedPath(path);
              }
            } else if (parser.getEventType() == XmlPullParser.END_TAG) {
              if ("transaction".equals(parser.getName()) && resultTransaction != null) {
                context.add(resultTransaction);
                resultTransaction = null;
              }
            }
          } 
          return Boolean.valueOf((context != null));
        }

            casz Joseph Petersen (old)
            zhangfengsun Zhangfeng Sun
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: