diff --git a/Jenkinsfile b/Jenkinsfile index 33925d7..5cae47b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,14 +10,15 @@ pipeline { } environment { - ACR_REGISTRY = 'crpi-n44qjpuucgjt8e8c.cn-beijing.personal.cr.aliyuncs.com' - ACR_NAMESPACE = 'xuqmgroup' - ACR_USERNAME = 'xuqinmin12' - PROD_HOST = '106.54.23.149' - PROD_USER = 'ubuntu' - COMPOSE_FILE = '/opt/xuqm/deploy/compose.production.yaml' - VERSIONS_FILE = '/opt/xuqm/deploy/versions.json' - DOCKER_BUILDKIT = '1' + ACR_REGISTRY = 'crpi-n44qjpuucgjt8e8c.cn-beijing.personal.cr.aliyuncs.com' + ACR_NAMESPACE = 'xuqmgroup' + ACR_USERNAME = 'xuqinmin12' + PROD_HOST = '106.54.23.149' + PROD_USER = 'ubuntu' + COMPOSE_FILE = '/opt/xuqm/deploy/compose.production.yaml' + VERSIONS_FILE = '/opt/xuqm/deploy/versions.json' + DOCKER_BUILDKIT = '1' + JAVA_TOOL_OPTIONS = '-Dfile.encoding=UTF-8 -Dstdout.encoding=UTF-8 -Dstderr.encoding=UTF-8' } options { @@ -80,6 +81,7 @@ pipeline { def latestImage = "${base}:latest" echo "Building ${svc}:${ver}..." bat """ + chcp 65001 >nul docker login ${ACR_REGISTRY} -u ${ACR_USERNAME} -p %ACR_PASS% if %errorlevel% neq 0 exit /b 1 docker pull --platform=linux/amd64 ${latestImage} || echo Pull failed, will build fresh @@ -110,6 +112,7 @@ pipeline { echo "Deploying ${svc}..." retry(2) { bat """ + chcp 65001 >nul ssh -i "%SSH_KEY%" -o StrictHostKeyChecking=no ${PROD_USER}@${PROD_HOST} "docker image prune -f 2>/dev/null || true; docker pull ${latestImage} || exit 1; docker compose -f ${COMPOSE_FILE} up -d --no-deps --force-recreate ${svc} || exit 1; docker image prune -f" """ } @@ -145,6 +148,7 @@ print('versions.json updated, platformVersion=' + d.get('platformVersion', '')) """.stripIndent() writeFile file: 'update_versions.py', text: updateScript bat """ + chcp 65001 >nul scp -i "%SSH_KEY%" -o StrictHostKeyChecking=no update_versions.py ${PROD_USER}@${PROD_HOST}:/tmp/update_versions.py ssh -i "%SSH_KEY%" -o StrictHostKeyChecking=no ${PROD_USER}@${PROD_HOST} "python3 /tmp/update_versions.py && rm /tmp/update_versions.py" """ @@ -161,6 +165,7 @@ print('versions.json updated, platformVersion=' + d.get('platformVersion', '')) def versionFiles = serviceVersions.keySet().collect { "VERSION.${it}" }.join(' ') def summary = serviceVersions.collect { svc, ver -> "${svc}=${ver}" }.join(', ') bat """ + chcp 65001 >nul git config user.email "jenkins@xuqm.com" git config user.name "Jenkins CI" git add ${versionFiles}