【问题标题】:Bitbucket Pipeline - how to exclude files or folders?Bitbucket Pipeline - 如何排除文件或文件夹?
【发布时间】:2021-10-07 16:10:16
【问题描述】:

如何排除文件夹或文件上传到服务器?

我想忽略“src”文件夹和 package.json。

# -----
image: node:10.15.3

pipelines:
  branches:
    develop:
    - step:
        caches:
        - node
        name: Deploy to develop (Nino) Continuous integration.
        script: # Modify the commands below to build your repository.
          - echo 'Deploying.. hold your horses!'
          - yarn install
          - yarn dev
          - pipe: atlassian/sftp-deploy:0.4.1
            variables:
                USER: $USER
                PASSWORD: $ROOT_PASSWORD
                SERVER: $SERVER
                REMOTE_PATH: /var/www/html/wordpress-starter/
                DEBUG: 'false'

【问题讨论】:

    标签: git continuous-integration bitbucket bitbucket-pipelines


    【解决方案1】:

    你可以试试这个

    EXTRA_ARGS: '--exclude=YOUR_DESIRE_FOLDER_PATH/*'
    

    更多信息请查看this

    【讨论】:

    • 如何排除多个文件和文件夹?
    • 您不能将 --exclude 与 sftp-deploy 管道一起使用,因为并非所有管道都支持此参数。但是,--exclude 选项不能与 rsync-deploy 管道一起使用。
    【解决方案2】:

    如果您不想排除多个文件或目录,您应该考虑使用rsync-deploy 管道:

    script:
      - pipe: atlassian/rsync-deploy:0.3.2
        variables:
          USER: 'ec2-user'
          SERVER: '127.0.0.1'
          REMOTE_PATH: '/var/www/build/'
          LOCAL_PATH: 'build'
          DEBUG: 'true'
          EXTRA_ARGS: '--exclude=src/* --exclude=package.json'
    

    【讨论】:

      【解决方案3】:

      您可以反过来,在每个步骤中指定要作为触发器包含的文件夹:

      - step:
                name: ...
                image: ...
                script:
                    - ...
                condition:
                    changesets:
                       includePaths:
                         - "folder1/*"
                         - "folder2/*"
      

      在此示例中,该步骤仅在文件夹 1 或文件夹 2 更改时运行。 在这里找到它:https://dev.to/omar16100/trigger-bitbucket-pipeline-only-if-certain-files-are-changed-with-google-cloud-functions-1abc

      【讨论】:

        猜你喜欢
        • 2023-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-12-30
        • 1970-01-01
        • 2013-06-15
        • 1970-01-01
        相关资源
        最近更新 更多