在Jenkins中使用简单的声明性管道时,我遇到了一个不一致之处,我可以手动运行docker run命令来发布我的expo项目。但是,当詹金斯创建docker容器并尝试运行expo publish命令时,出现连接拒绝错误。我最初的猜测是将特权添加到docker容器,然后确保用户可以以root用户身份运行……这实际上没有帮助。我很好奇是否有人想出如何使用Jenkins作为促进这一目的的主要方式在docker容器内运行expo CI / CD。
+ EXPO_DEBUG=true npx expo publish --non-interactive --release-channel develop
[07:50:24] Publishing to channel 'develop'...
[07:50:26] We noticed you did not build a standalone app with this SDK version and release channel before. Remember that OTA updates will not work with the app built with different SDK version and/or release channel. Read more: https://docs.expo.io/versions/latest/guides/publishing.html#limitations
[07:50:27] Building iOS bundle
[07:50:27] connect ECONNREFUSED 127.0.0.1:19001
[07:50:27] Error: connect ECONNREFUSED 127.0.0.1:19001
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1113:14)
我的Jenkinsfile很简单:
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
}
}
stages {
stage('slack notification') {
agent none
steps {
slackSend color: "good", message: "Build Started - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>)"
}
}
stage('run tests') {
steps {
sh 'cd /project && yarn test'
}
}
stage ('publish to expo') {
environment {
expo_creds = credentials('expo_credentials')
}
steps {
sh "npx expo login -u $expo_creds_USR -p $expo_creds_PSW && mv env.beta.ts env.ts && EXPO_DEBUG=true npx expo publish --non-interactive --release-channel ${env.BRANCH_NAME}"
}
}
}
post {
success {
slackSend color: "good", message: "Build Finished - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) duration: ${currentBuild.durationString}"
}
unstable {
slackSend color: "warning", message: "Build Unstable - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) duration: ${currentBuild.durationString}"
}
failure {
slackSend color: "danger", message: "Build Failed - ${env.JOB_NAME} ${env.BUILD_NUMBER} (<${env.BUILD_URL}|Open>) duration: ${currentBuild.durationString}"
}
}
}
我的Dockerfile如下所示:
FROM node:10.13-alpine as npm-dependencies
WORKDIR /project
RUN apk add --no-cache \
autoconf \
libtool \
automake \
g++ \
make \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
nasm
COPY yarn.lock .
COPY package.json .
COPY .npmrc .
RUN yarn install
FROM node:10.13-jessie
WORKDIR /project
COPY custom_types ./custom_typess
COPY img ./img
COPY assets ./assets
COPY src ./src
COPY tests ./tests
COPY babel.config.js ./
COPY .buckconfig ./
COPY .flowconfig ./
COPY .watchmanconfig ./
COPY app.json .
COPY App.js .
COPY env.docker.ts ./env.ts
COPY tsconfig.json .
COPY package.json .
COPY jest.config.js .
COPY --from=npm-dependencies /project/node_modules /project/node_modules
RUN npm install -g expo-cli
RUN mkdir /.npm && chmod 0777 /.npm
RUN mkdir /.cache && chmod 0777 /.cache
RUN mkdir /.yarn && chmod 0777 /.yarn
RUN mkdir /.expo && chmod 0777 /.expo
RUN mkdir /project/.expo && chmod 0777 /project/.expo
答案 0 :(得分:0)
好的,所以这实际上只是特定于博览会的,可能是其制作方式的错误。完成登录步骤后,我手动将CD输入/ project目录,然后输入rm -rf .expo。
将CWD设置为/ project,然后删除.expo可以解决此问题。为什么它在詹金斯之外而不是在里面起作用,仍然有些令人困惑;但是,这两个动作的结合为我解决了这个问题。