Bitbucket管道-构建不输出构建文件?

时间:2019-07-22 20:35:33

标签: bitbucket bitbucket-pipelines

我最近开始使用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/**

1 个答案:

答案 0 :(得分:2)

您的管道步骤顺序错误。

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'