【问题标题】:Jenkins slave with nodejs to run npm publishJenkins 从机与 nodejs 运行 npm publish
【发布时间】:2020-01-13 10:37:33
【问题描述】:

我有一个安装 nodejs 的 dockerfile。我从该 dockerfile 创建一个容器以用作 jenkins 中的从属。问题是当我尝试发布(npm publish --registry ...)时,它说我需要先登录。但是我不能在 jenkins 文件中使用 npm adduser ,因为您必须在需要时手动输入用户名和密码。我尝试使用有效令牌添加文件 .nmrw,但没有成功。任何想法? 最好的问候。

FROM jenkins/ssh-slave

# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl 

# Install nodejs        
RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN apt-get install -y nodejs && apt-get install -y nginx   

【问题讨论】:

  • 完成了。我做到了:)

标签: node.js jenkins-pipeline dockerfile


【解决方案1】:

密钥在文件 .npmrc 中。您必须拥有发布到的同一台服务器。

FROM jenkins/ssh-slave

# Install selected extensions and other stuff
RUN apt-get update && apt-get -y --no-install-recommends install && apt-get clean
RUN apt-get install -y curl 
ARG NODEJS_VERSION=setup_11.x

# Install nodejs    
RUN curl -sL https://deb.nodesource.com/${NODEJS_VERSION} | bash - && apt-get install -y nodejs && apt-get install -y nginx 

RUN chown -R jenkins:jenkins /home/jenkins &&  chmod -R 777 /home/jenkins
COPY .npmrc /home/jenkins/.npmrc 

RUN npm -v 

【讨论】:

    猜你喜欢
    • 2016-03-07
    • 1970-01-01
    • 2019-10-31
    • 2021-08-26
    • 1970-01-01
    • 2019-08-29
    • 1970-01-01
    • 2018-01-21
    • 2015-11-19
    相关资源
    最近更新 更多