setup to fetch refs/changes
only
Copy # Refspec
refs/changes/*:refs/remotes/origin/changes/*
setup to fetch only refs/heads/sandbox/marslo/*
Copy # Refspec
refs/heads/sandbox/marslo/*:refs/remotes/origin/heads/sandbox/marslo/*
Copy # Refspec
$GERRIT_REFSPEC:$GERRIT_REFSPEC
# branch
$GERRIT_REFSPEC
# or
FETCH_HEAD
Copy $ curl -O https://repo1.maven.org/maven2/com/github/mwiede/jsch/0.2.7/jsch-0.2.7.jar
$ docker cp jsch-0.2.7.jar e6cd5d7516cd:/var/jenkins_home/plugins/jsch/WEB-INF/lib/jsch-0.1.55.jar
# ^
# Docker Container ID
Copy import org . jenkinsci . plugins . jsch . JSchConnector
import java . io . InputStream
import com . jcraft . jsch . JSch
import com . jcraft . jsch . Session
import com . jcraft . jsch . LocalIdentityRepository
import com . jcraft . jsch . Channel
import com . jcraft . jsch . ChannelExec
String user = 'srv-ssd-fw-devops'
String host = 'sample.gerrit.com'
int port = 29418
String path = System. getProperty( 'user.home' ) + '/.ssh/ed25519/devops@ssdfw'
// Byte[] privateKey = ''.getBytes()
JSch jsch = new JSchConnector ( user, host, port ) . getJSch()
jsch . addIdentity( path )
Session session = jsch . getSession( user, host, port )
session . setConfig( 'StrictHostKeyChecking' , 'no' )
session . setConfig( 'HostkeyAlgorithms' , '+ssh-rsa' )
session . setConfig( 'PreferredAuthentications' , 'publickey' )
println """
${session.getClass()}:
session client version : ${session.getClientVersion()} : ${session.clientVersion}
session host : ${session.getHost()} : ${session.host}
session port : ${session.getPort()} : ${session.port}
session hostkey : ${session.getHostKey()} : ${session.hostKey}
session hostkey alias : ${session.getHostKeyAlias()} : ${session.hostKeyAlias}
session isConnected : ${session.isConnected()}
"""
def knowHosts = session . getHostKeyRepository()
println """
${knowHosts.getClass()}:
knownHosts host key : ${knowHosts.getHostKey( host, 'ssh-rsa' )}
knowHosts repository id : ${knowHosts.getKnownHostsRepositoryID()}
"""
def idRepo = jsch . getIdentityRepository()
println """
${idRepo.getClass()} :
identityRepository name : ${idRepo.getName()} : ${idRepo.name}
identityRepository status : ${idRepo.getStatus()} : ${idRepo.status}
identityRepository identities : ${idRepo.getIdentities()} : ${idRepo.identities}
"""
session . connect()