• Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • bazaar-plugin
    • None

      The current Bazaar plugin does not provide a way to specify a subdirectory that could be used to "bzr branch" a URL in a multiple SCM job.

          [JENKINS-18955] Add multiple scm support to Bazaar plugin

          Currently there is a casting issue and the Bazaar plugin cleanup the home directory of the job, deleting the previous SCMs.

          Maxime Chambreuil added a comment - Currently there is a casting issue and the Bazaar plugin cleanup the home directory of the job, deleting the previous SCMs.

          Hi,

          Concerning the 2 pb underlined by Maxime I have developped 2 quick patches.

          Problem 1 : the bazaar plugin is not compatible with multiple SCM plugin (https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin)

          • The error : a classcast exception :
          " stderr: ""
          FATAL: org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState cannot be cast to hudson.plugins.bazaar.BazaarRevisionState
          java.lang.ClassCastException: org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState cannot be cast to hudson.plugins.bazaar.BazaarRevisionState
          	at hudson.plugins.bazaar.BazaarSCM.buildEnvVars(BazaarSCM.java:460)
          	at org.jenkinsci.plugins.multiplescms.MultiSCM.buildEnvVars(MultiSCM.java:71)
          	at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:938)
          	at hudson.plugins.bazaar.BazaarSCM.cleantree(BazaarSCM.java:340)
          	at hudson.plugins.bazaar.BazaarSCM.update(BazaarSCM.java:279)
          ...
          
          • Solution : please find below the modification to hudson.plugins.bazaar.BazaarSCM#buildEnvVars :
              @Override
              public void buildEnvVars(AbstractBuild<?,?> build, Map<String, String> env) {
                  // modification to avoid ClassCastException when used with MultiSCM jenkins plugin
                  // with this cast those 2 variables won't be usable in multiscm : BZR_REVISION, BZR_REVID.
                  SCMRevisionState revisionState = build.getAction(SCMRevisionState.class);
                  if (revisionState != null && revisionState instanceof BazaarRevisionState) {
                      BazaarRevisionState revisionState1 = (BazaarRevisionState) revisionState;
                    if (revisionState1.getRevNo() != null) {
                      env.put("BZR_REVISION", revisionState1.getRevNo());
                    }
                    if (revisionState1.getRevId() != null) {
                      env.put("BZR_REVID", revisionState1.getRevId());
                    }
                  }
              }
          
          

          Julien Boumard added a comment - Hi, Concerning the 2 pb underlined by Maxime I have developped 2 quick patches. Problem 1 : the bazaar plugin is not compatible with multiple SCM plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Multiple+SCMs+Plugin ) The error : a classcast exception : " stderr: "" FATAL: org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState cannot be cast to hudson.plugins.bazaar.BazaarRevisionState java.lang.ClassCastException: org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState cannot be cast to hudson.plugins.bazaar.BazaarRevisionState at hudson.plugins.bazaar.BazaarSCM.buildEnvVars(BazaarSCM.java:460) at org.jenkinsci.plugins.multiplescms.MultiSCM.buildEnvVars(MultiSCM.java:71) at hudson.model.AbstractBuild.getEnvironment(AbstractBuild.java:938) at hudson.plugins.bazaar.BazaarSCM.cleantree(BazaarSCM.java:340) at hudson.plugins.bazaar.BazaarSCM.update(BazaarSCM.java:279) ... Solution : please find below the modification to hudson.plugins.bazaar.BazaarSCM#buildEnvVars : @Override public void buildEnvVars(AbstractBuild<?,?> build, Map< String , String > env) { // modification to avoid ClassCastException when used with MultiSCM jenkins plugin // with this cast those 2 variables won't be usable in multiscm : BZR_REVISION, BZR_REVID. SCMRevisionState revisionState = build.getAction(SCMRevisionState.class); if (revisionState != null && revisionState instanceof BazaarRevisionState) { BazaarRevisionState revisionState1 = (BazaarRevisionState) revisionState; if (revisionState1.getRevNo() != null ) { env.put( "BZR_REVISION" , revisionState1.getRevNo()); } if (revisionState1.getRevId() != null ) { env.put( "BZR_REVID" , revisionState1.getRevId()); } } }

          Problem 2 : the ability to work in a sub directory

          I added this feature (largely inspired from the git plugin). If you are interested, how could I send you the code ? On github ?

          Julien Boumard added a comment - Problem 2 : the ability to work in a sub directory I added this feature (largely inspired from the git plugin). If you are interested, how could I send you the code ? On github ?

          My github fork regarding thoses pb : https://github.com/laboumerde/bazaar-plugin

          Julien Boumard added a comment - My github fork regarding thoses pb : https://github.com/laboumerde/bazaar-plugin

          Any chance this gets into the next stable release?

          Sebastian Messerschmidt added a comment - Any chance this gets into the next stable release?

          Hi Sebastian,

          On my side I haven't had any news, so for now you can use the fork I made and it should work.

          Julien Boumard added a comment - Hi Sebastian, On my side I haven't had any news, so for now you can use the fork I made and it should work.

          Geoff Bache added a comment -

          Would also appreciate a release with this fix in... will try and use the fork for now.

          Geoff Bache added a comment - Would also appreciate a release with this fix in... will try and use the fork for now.

          Geoff Bache added a comment - - edited

          The fork seems to have another issue, which is that the "poll SCM" option does not work. It thinks there are changes every time it runs.

          For each repository, it says something like

          RevisionState revno:4667 revid:<myemailaddress>-20140616101102-6rmgq90kgyzcc92j
          Baseline is org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState@52f822c7.

          and I guess it reckons these are unequal and hence triggers a build.

          Geoff Bache added a comment - - edited The fork seems to have another issue, which is that the "poll SCM" option does not work. It thinks there are changes every time it runs. For each repository, it says something like RevisionState revno:4667 revid:<myemailaddress>-20140616101102-6rmgq90kgyzcc92j Baseline is org.jenkinsci.plugins.multiplescms.MultiSCMRevisionState@52f822c7. and I guess it reckons these are unequal and hence triggers a build.

            sdirector Monty Taylor
            max3903 Maxime Chambreuil
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: