首页 > 解决方案 > Lerna 使用 jenkins 管道发布

问题描述

我一直在经历试图让 lerna 在我的 ci 管道中发布的噩梦。

我已经设法从 git 中提取脚本来检查标签,并且我找到了withNPM管道插件。因为我lerna用于发布多个包,所以我必须将.npmrc插件在工作区中创建的文件移动到主目录的根目录,以便所有包都可以访问它。

NPM 插件使用 jenkins 配置文件来创建.npmrc文件。看起来像这样:

//registry.npmjs.com/:_authToken=TOKEN

这是我的 Jenkins 管道中的内容。

stage('lerna publish') {
    steps {
        withCredentials([sshUserPrivateKey(credentialsId: 'cb8acd82-3a50-4a94-9d5f-44b04856e6fd', keyFileVariable: 'GITHUB_KEY')]) {
            sh 'echo ssh -i $GITHUB_KEY -l git -o StrictHostKeyChecking=no \\"\\$@\\" > ./run_ssh.sh'
            sh 'chmod +x ./run_ssh.sh'
            withEnv(['GIT_SSH=./run_ssh.sh']) {
                withNPM(npmrcConfig: 'da4e5199-b04b-41b6-a03f-dfbcc344f701') {
                    sh "rm -rf ~/.npmrc"
                    sh 'mv ./.npmrc ~/.npmrc'
                    sh 'npm config set registry https://registry.npmjs.com/'
                    sh 'git config --global user.email "thomas@reggi.com"'
                    sh 'git config --global user.name "reggi"'
                    sh 'git checkout master'
                    sh 'git pull origin master --force'
                    sh 'npm run lerna-publish'
                }
            }
        }
    }
}

这是错误:

lerna info auto-confirmed 
lerna info publish Publishing packages to npm...
lerna ERR! npm publish --ignore-scripts exited 1 in '@reggi/help.filter-until'
lerna ERR! npm publish --ignore-scripts stderr:
npm notice 
npm notice package: @reggi/help.filter-until@0.0.20
npm notice === Tarball Contents === 
npm notice 1.5kB package.json  
npm notice 609B  index.build.js
npm notice === Tarball Details === 
npm notice name:          @reggi/help.filter-until                
npm notice version:       0.0.20                                  
npm notice package size:  997 B                                   
npm notice unpacked size: 2.1 kB                                  
npm notice shasum:        a6db6d4dc02f05548c22fe2e034832ac02252633
npm notice integrity:     sha512-6oAFaXqZMREsh[...]GnMcnIxXUBINg==
npm notice total files:   2                                       
npm notice 
npm ERR! code ENEEDAUTH
npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

我发现我与上面的网址不一致,并将它们都更改为.com,现在我遇到了这个问题:

lerna info auto-confirmed 
lerna info publish Publishing packages to npm...
lerna ERR! npm publish --ignore-scripts exited 1 in '@reggi/help.filter-until'
lerna ERR! npm publish --ignore-scripts stderr:
npm notice 
npm notice package: @reggi/help.filter-until@0.0.23
npm notice === Tarball Contents === 
npm notice 1.5kB package.json  
npm notice 609B  index.build.js
npm notice === Tarball Details === 
npm notice name:          @reggi/help.filter-until                
npm notice version:       0.0.23                                  
npm notice package size:  1.0 kB                                  
npm notice unpacked size: 2.1 kB                                  
npm notice shasum:        60ee325b219abdae06a75cfe45bc66096f715187
npm notice integrity:     sha512-o4ahyOWAsUk3j[...]O/3MH2Tpv1tOQ==
npm notice total files:   2                                       
npm notice 
npm ERR! publish Failed PUT 404
npm ERR! code E404
npm ERR! 404 Not found : @reggi/help.filter-until
npm ERR! 404 
npm ERR! 404  '@reggi/help.filter-until' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

标签: node.jsjenkinsnpmjenkins-pipelinelerna

解决方案


我有使用.org域的令牌设置和设置为域的注册表.com。:(


推荐阅读