尝试将节点项目发布到Nexus时出错[Jenkins-Nodejs]

9gm1akwq  于 2022-11-21  发布在  Jenkins
关注(0)|答案(1)|浏览(197)

使用Jenkins,我在尝试将节点项目(React应用程序)发布到Nexus时遇到错误。

管道脚本:

node ("test-label") {
    stage('checkout'){
            sh 'git clone -b react-1 https://gitlab.com/.../ui/test.git .'
    }
    stage ('Build'){
        container('node'){
            script {
                sh "set +x && echo \"//mynexusurl/repository/npm-private/:_authToken=NpmToken.******\" >> .npmrc"
                sh 'npm publish'
          }
        }
    }
}

错误:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`

如果我将下面的代码添加到项目的package.json文件中,它将正常工作,但是我不想在package.json文件中输入此信息。

"publishConfig": {
    "registry": "http://mynexus/repository/npm-private/"
}

如何在不提供publishConfig信息的情况下修复package.json*?

of1yzvn4

of1yzvn41#

我修复了这个问题,如下所示

sh "npm publish --registry http://nexusurl/repository/npm-private/"

相关问题