* 원격 서버가 공개키 인증 허용 설정
/etc/ssh/sshd_config 주요 항목 yes 아니면 사용불가
# 공개키 인증 허용
PubkeyAuthentication yes <==== ***** 설정 확인
pipeline {
agent any
environment {
MAVEN_HOME = 'maven-3.9.3'
REMOTE_TOMCAT_DIR = '/home/hosting_users/khan666/tomcat/webapps'
}
stages {
stage('Checkout') {
steps {
git url: 'https://github.com/K84N666LEE/Digital2U.git', branch: 'main'
}
}
stage('Build WAR') {
steps {
bat "C:\\app\\apache-maven-3.9.3\\bin\\mvn clean package"
}
}
stage('Deploy to Cafe24 via SSH') {
steps {
script {
def warFile = findFiles(glob: '**/target/*.war')[0].path
//def warFile = 'C:\\app\\workspace\\Digital2U\\target/ROOT.war'
def remoteFile = "${REMOTE_TOMCAT_DIR}\\ROOT.war"
// 개인키 경로 (예: C:\Users\yourname\.ssh\id_rsa)
def privateKeyPath = 'C:\\Users\\newadmin\\.ssh\\id_rsa'
// Cafe24 배포: SCP
// digital2u.co.kr 은 IP로 대체 가능함 !!!!!!!!!
bat """
scp -i "${privateKeyPath}" -o StrictHostKeyChecking=no ${warFile} khan666@digital2u.co.kr:${remoteFile}
"""
// Tomcat 재시작 (Cafe24는 일부 계정에서 shell 접근 제한될 수 있음 - 가능 시만 사용)
bat """
ssh -i "${privateKeyPath}" -o StrictHostKeyChecking=no khan666@digital2u.co.kr ^
"ps -ef | grep tomcat | grep -v grep | awk '{print \$2}' | xargs kill -9; \
nohup /home/hosting_users/khan666/tomcat/bin/startup.sh &"
"""
}
}
}
}
}
* 아래의 명령어로 테스트
C:\Users\newadmin\.jenkins\workspace\DIGITAL2U_Local>scp -i "C:\Users\newadmin\.ssh\id_rsa" -o StrictHostKeyChecking=no "C:\Users\newadmin\.jenkins\workspace\DIGITAL2U_Local\target\ROOT.war" khan666@172.23.93.175:/home/khan666/tomcat/webapps/ROOT.war
|