diff --git a/Jenkinsfile b/Jenkinsfile index 494b92a..934a7d0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -79,6 +79,26 @@ pipeline { } } } + + stage('Publish Private SDK to Nexus') { + steps { + withCredentials([usernamePassword(credentialsId: 'NEXUS_CREDS', passwordVariable: 'NPM_PASS', usernameVariable: 'NPM_USER')]) { + bat """ + powershell -NonInteractive -Command "Set-Content .npmrc ('//nexus.xuqinmin.com/repository/npm-hosted/:_auth=' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(\$env:NPM_USER + ':' + \$env:NPM_PASS))) -Encoding ASCII" + npm publish --userconfig .npmrc --registry %NEXUS_REGISTRY% --pack-destination dist-private-tmp || exit 0 + node -e "const fs=require('fs'); const p=JSON.parse(fs.readFileSync('package.private.json')); fs.writeFileSync('package.json.bak', fs.readFileSync('package.json')); fs.writeFileSync('package.json', JSON.stringify(p,null,2));" + npm publish --registry %NEXUS_REGISTRY% + move /Y package.json.bak package.json + """ + } + } + post { + always { + bat 'del .npmrc 2>nul || exit 0' + bat 'if exist package.json.bak move /Y package.json.bak package.json' + } + } + } } post {