【问题标题】:Bitbucket Pipelines - Build not outputting the build files?Bitbucket Pipelines - 构建不输出构建文件?
【发布时间】:2019-11-30 20:43:05
【问题描述】:

我最近开始使用 Bitbucket Pipelines 处理 CI。我已经设法使用我的 SFTP 服务器进行连接,创建 API 公钥和私钥并使用 SSH 将它们添加到我的服务器。

现在,当我运行构建时,它会将我的所有文件上传到正确的文件夹。但是我遇到了一个问题,即从脚本“yarn build”运行 package.json 命令完全没有做任何事情。根文件夹中没有任何内容。

我错过了什么或做错了什么?本地一切正常,上传文件也是如此。

我的 bitbucket-pipeline.yaml:

# This is a sample build configuration for JavaScript.
# Check our guides at https://confluence.atlassian.com/x/14UWN for more examples.
# Only use spaces to indent your .yml configuration.
# -----
# You can specify a custom docker image from Docker Hub as your build environment.
image: node:10.15.3

pipelines:
  branches:
    develop:
    - step:
        name: Lets push the data to the Server.
        caches:
        - node
        script:
          - pipe: atlassian/sftp-deploy:0.4.1
            variables:
                USER: $SFTP_username
                PASSWORD: $SFTP_password
                SERVER: $SFTP_host
                REMOTE_PATH: /var/www/html/pipeline-http/test-website/
                DEBUG: 'true'
    - step:
        name: Build and test website and deploy.
        caches:
          - node
        script:
          - yarn install
          - yarn test-build
        artifacts:
          - assets/**

【问题讨论】:

  • 根文件夹里什么都没有是什么意思?
  • Druze,当我在我的计算机上运行“yarn test-build”时,Webpack 将创建一个包含已编译的 CSS 和 JS 文件的“assets”文件夹。但是,当我使用 CI 运行它并运行命令时,不会创建文件夹或根本不存在文件。
  • 你解决了这个问题吗,我最近遇到了完全相同的问题。

标签: bitbucket bitbucket-pipelines


【解决方案1】:

您的管道步骤顺序错误。

Bitbucket 管道在云端执行,这意味着您必须先构建项目,然后将所有内容复制到服务器(因为它无法真正在服务器上复制和构建项目)

对于您的情况,这应该是正确的解决方案

  branches:
    develop:
    - step:
        name: Build and test website and deploy.
        caches:
          - node
        script:
          - yarn install
          - yarn test-build
        artifacts:
          - assets/**
    - step:
        name: Lets push the data to the Server.
        caches:
        - node
        script:
          - pipe: atlassian/sftp-deploy:0.4.1
            variables:
                USER: $SFTP_username
                PASSWORD: $SFTP_password
                SERVER: $SFTP_host
                REMOTE_PATH: /var/www/html/pipeline-http/test-website/
                DEBUG: 'true'


【讨论】:

  • 由于某种原因,我现在已经尝试过了,构建永远不会继续到第二步,这是我的输出。 + yarn test-build yarn run v1.13.0 $ NODE_ENV=development BROWSERSLIST_ENV=development webpack -d --config ./webpack/webpack.config.babel.js [hardsource:8656a567] Writing new cache 8656a567... [hardsource:8656a567 ] 跟踪节点依赖项:package-lock.json、yarn.lock。 DONE 在 3673ms9:02:46 PM 编译成功 使用 Ctrl+C 关闭它 继续加载 "test-build": "NODE_ENV=development BROWSERSLIST_ENV=development webpack -d --config ./webpack/webpack.config.babel.js"
  • test-build 发生了一些奇怪的事情,尝试删除它只是为了测试我们的代码在服务器上运行
  • 啊,这是“浏览器同步”,通过注释掉一切正常。哈瓦拉蒂
  • 只需将它们添加到 .gitignore 并清除 git 缓存
  • Nemas frku :)。如果对您来说更容易,我们可以切换到聊天
猜你喜欢
  • 2017-12-10
  • 1970-01-01
  • 2019-04-08
  • 2022-08-07
  • 1970-01-01
  • 2019-01-19
  • 2014-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多