continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r1126667 - in /continuum/trunk: continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ continuum-release/ continuum-release/src/main/java/org/apache/maven/continuum/release/phase/
Date Mon, 23 May 2011 19:08:15 GMT
Author: oching
Date: Mon May 23 19:08:15 2011
New Revision: 1126667

URL: http://svn.apache.org/viewvc?rev=1126667&view=rev
Log:
[CONTINUUM-2628] 
o use credentials in scm url if specified on update working copy phase in continuum-release.
otherwise, use scm credentials of project

Modified:
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java
    continuum/trunk/continuum-release/pom.xml
    continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java

Modified: continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java?rev=1126667&r1=1126666&r2=1126667&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/ContinuumScmUtils.java
Mon May 23 19:08:15 2011
@@ -10,7 +10,7 @@ import org.apache.maven.scm.provider.git
  */
 public class ContinuumScmUtils
 {
-    private static final String GIT_SCM_PROVIDERTYPE = "git";
+    public static final String GIT_SCM_PROVIDERTYPE = "git";
 
     // CONTINUUM-2628
     public static ContinuumScmConfiguration setSCMCredentialsforSSH( ContinuumScmConfiguration
config,

Modified: continuum/trunk/continuum-release/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/pom.xml?rev=1126667&r1=1126666&r2=1126667&view=diff
==============================================================================
--- continuum/trunk/continuum-release/pom.xml (original)
+++ continuum/trunk/continuum-release/pom.xml Mon May 23 19:08:15 2011
@@ -54,6 +54,10 @@ under the License.
       <artifactId>continuum-api</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.continuum</groupId>
+      <artifactId>continuum-scm</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-settings</artifactId>
     </dependency>

Modified: continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java?rev=1126667&r1=1126666&r2=1126667&view=diff
==============================================================================
--- continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java
(original)
+++ continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/phase/UpdateWorkingCopyPhase.java
Mon May 23 19:08:15 2011
@@ -22,6 +22,8 @@ package org.apache.maven.continuum.relea
 import java.io.File;
 import java.util.List;
 
+import org.apache.commons.lang.StringUtils;
+import org.apache.continuum.scm.ContinuumScmUtils;
 import org.apache.maven.scm.ScmBranch;
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
@@ -32,6 +34,7 @@ import org.apache.maven.scm.manager.NoSu
 import org.apache.maven.scm.manager.plexus.PlexusLogger;
 import org.apache.maven.scm.provider.ScmProvider;
 import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmUrlUtils;
 import org.apache.maven.scm.provider.git.gitexe.command.branch.GitBranchCommand;
 import org.apache.maven.scm.provider.git.repository.GitScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
@@ -72,6 +75,53 @@ public class UpdateWorkingCopyPhase
 
         ScmRepository repository;
         ScmProvider provider;
+
+        // CONTINUUM-2628
+        // if git ssh, use credentials specified in scm url if present. otherwise, use the
scm credentials of project
+        String providerType = ScmUrlUtils.getProvider( releaseDescriptor.getScmSourceUrl()
);
+        String scmSpecificUrl = releaseDescriptor.getScmSourceUrl().substring( providerType.length()
+ 5 );
+
+        if( providerType.contains( ContinuumScmUtils.GIT_SCM_PROVIDERTYPE ) && scmSpecificUrl.startsWith(
GitScmProviderRepository.PROTOCOL_SSH ) )
+        {
+            scmSpecificUrl = scmSpecificUrl.substring( GitScmProviderRepository.PROTOCOL_SSH.length()
+ 3 );
+
+            // extract user information
+            int indexAt = scmSpecificUrl.indexOf( "@" );
+            String sshScmUsername = "";
+            String sshScmPassword = "";
+
+            if ( indexAt >= 0 )
+            {
+                String userInfo = scmSpecificUrl.substring( 0, indexAt );
+                sshScmUsername = userInfo;
+
+                int indexPwdSep = userInfo.indexOf( ":" );
+                // password is specified in the url
+                if ( indexPwdSep < 0 )
+                {
+                    sshScmUsername = userInfo.substring( indexPwdSep + 1);
+                }
+                else
+                {
+                    sshScmUsername = userInfo.substring( 0, indexPwdSep );
+                    sshScmPassword = userInfo.substring( indexPwdSep + 1 );
+                }
+            }
+
+            if( !StringUtils.isBlank( sshScmUsername ) )
+            {
+                releaseDescriptor.setScmUsername( sshScmUsername );
+                if( !StringUtils.isBlank( sshScmPassword ) )
+                {
+                    releaseDescriptor.setScmPassword( sshScmPassword );
+                }
+                else
+                {
+                    releaseDescriptor.setScmPassword( null );
+                }
+            }
+        }
+
         try
         {
             repository = scmRepositoryConfigurator.getConfiguredRepository( releaseDescriptor,
settings );



Mime
View raw message