Jenkins构建在功能分支和开发分支中的行为有所不同

时间:2019-11-13 18:03:51

标签: git docker jenkins

Jenkinsfile中用于构建docker映像的代码

inferred

功能分支构建Docker映像阶段日志。

def buildDocker(environment, imageTag, branchName, seedDb) {
    script {
        docker.withRegistry("https://${Config.registries[environment]}", "something-dev-local") {
            //push UI
            printTimestamp('Building UI Image')
            def etcUIImage = docker.build(
                "com.something.something.nothing.ui-apache-${environment}:${env.BUILD_ID}","--build-arg ENVIRONMENT=${environment} --build-arg SERVER_NAME=${Config.url[environment]} -f ui/HttpdDockerfile ./ui"
            )
            etcUIImage.push()
            etcUIImage.push("latest")
            printTimestamp('Finished Building UI Image')
        }
    }
}

Development分支构建Docker Image Stage Logs。

16:49:42 ********Building UI Image********
[Pipeline] echo
16:49:42 11/13/2019 16:49:42
[Pipeline] sh
16:49:42 [sfile_dockerfile_slave_node-2XQBHWLAHN2L7X3TLT6Y3M] Running shell script
16:49:42 + docker build -t com.something.something.nothing.ui-apache-dev:1 --build-arg ENVIRONMENT=dev --build-arg SERVER_NAME=SERVER_NAME -f ui/HttpdDockerfile ./ui
16:49:43 Sending build context to Docker daemon  5.531MB

16:49:43 Step 1/19 : FROM node:11.1.0-alpine AS build
16:49:43  ---> 4b3c025f5508
16:49:43 Step 2/19 : WORKDIR /app
16:49:43  ---> Using cache
16:49:43  ---> cf31145d47fa
16:49:43 Step 3/19 : COPY . .
16:49:43  ---> Using cache
16:49:43  ---> cb1f45f16874
16:49:43 Step 4/19 : RUN npm cache clean --force &&   npm install --verbose &&   npm run build
16:49:43  ---> Using cache
16:49:43  ---> 783d4ee9bb3f
16:49:43 Step 5/19 : FROM httpd:2.4
16:49:43  ---> d3017f59d5e2
16:49:43 Step 6/19 : ARG SERVER_NAME
16:49:43  ---> Using cache
16:49:43  ---> 26c07a41b225
16:49:43 Step 7/19 : ARG ENVIRONMENT
16:49:43  ---> Using cache
16:49:43  ---> d6964c2e5915
16:49:43 Step 8/19 : ENV http_proxy http://IP:3128
16:49:43  ---> Using cache
16:49:43  ---> e778131d5e43
16:49:43 Step 9/19 : ENV https_proxy http://IP:3128
16:49:43  ---> Using cache
16:49:43  ---> 66aa74361295

-> 这些是红色的

   17:28:14 [m.rxcorp.etc.ui_development-2SIB5HIBN6VHTSRFBL4C6U3Q3FH] Running shell script
17:28:14 + docker build -t com.something.something.nothing.ui-apache-dev:81 --build-arg ENVIRONMENT=dev --build-arg SERVER_NAME=SERVER_NAME -f ui/HttpdDockerfile ./ui
17:28:14 Sending build context to Docker daemon  5.531MB

17:28:14 Step 1/19 : FROM node:11.1.0-alpine AS build
17:28:15 11.1.0-alpine: Pulling from library/node
17:28:15 4fe2ade4980c: Pulling fs layer
17:28:15 a3f62ee5351e: Pulling fs layer
17:28:15 b8ee302f1a47: Pulling fs layer
17:28:15 b8ee302f1a47: Verifying Checksum
17:28:15 b8ee302f1a47: Download complete
17:28:15 4fe2ade4980c: Verifying Checksum
17:28:15 4fe2ade4980c: Download complete
17:28:15 a3f62ee5351e: Verifying Checksum
17:28:15 a3f62ee5351e: Download complete
17:28:15 4fe2ade4980c: Pull complete
17:28:19 a3f62ee5351e: Pull complete
17:28:19 b8ee302f1a47: Pull complete
17:28:19 Digest: sha256:324ccac1d7c4ddf5eb9f9ed5274c37c90965605b5eb68df0a67c6266837bfb79
17:28:19 Status: Downloaded newer image for node:11.1.0-alpine
17:28:19  ---> 4b3c025f5508
17:28:19 Step 2/19 : WORKDIR /app
17:28:19  ---> Running in dc15efe514eb
17:28:19 Removing intermediate container dc15efe514eb
17:28:19  ---> 84a182a3dfe6
17:28:19 Step 3/19 : COPY . .
17:28:19  ---> 07fb1ca55828
17:28:19 Step 4/19 : RUN npm cache clean --force &&   npm install --verbose &&   npm run build
17:28:19  ---> Running in 50e659b57e76

这部分持续2个小时,然后使阶段失败。我认为这与我们正在使用的从属代理有关,但是为什么开发分支与功能分支之间存在差异。

构建docker阶段的詹金斯文件代码:

17:28:20 npm WARN using --force I sure hope you know what you are doing.
17:28:20 npm info it worked if it ends with ok
17:28:20 npm verb cli [ '/usr/local/bin/node',
17:28:20 npm verb cli   '/usr/local/bin/npm',
...
17:28:32 npm http fetch GET 200 https://registry.npmjs.org/react-scripts/-/react-scripts-2.1.5.tgz 335ms
17:28:32 npm http fetch GET 200 https://registry.npmjs.org/yargs/-/yargs-11.1.0.tgz 310ms
17:28:32 npm http fetch GET 200 https://registry.npmjs.org/redux/-/redux-4.0.4.tgz 335ms
...
17:29:04 npm info lifecycle raw-body@2.3.3~preinstall: raw-body@2.3.3
17:29:04 npm info lifecycle finalhandler@1.1.1~preinstall: finalhandler@1.1.1
...

问题是,为什么开发分支一直使用这些红色的npm东西永远在docker构建阶段继续进行?

1 个答案:

答案 0 :(得分:0)

要消除原因,您可以尝试在开发分支构建成功的代理上运行功能分支构建吗?

检查您要尝试从中重新下载模块的主机的互联网连接(在运行故障代理的主机上)。全新下载将花费时间,而不是2个小时,并且可能是防火墙阻止了传出连接。

尝试在浏览器上访问npm存储库,对域执行ping操作。检查防火墙出站规则/ iptables。