【问题标题】:Create specifc folder from Gitlab CI artifacts after building with Gulp使用 Gulp 构建后从 Gitlab CI 工件创建特定文件夹
【发布时间】:2017-03-13 12:55:29
【问题描述】:

几周前我在这里得到了一些帮助,因为我以前从未使用过 gitlab ci。我已经取得了不错的成绩,现在在我的最后一部分中,将 Gulp 的输出包含在工件 zip 中。

所以目前我的构建 .yml 文件如下所示:

cache:
  paths:
  - vendor/
  - node_modules/
before_script:
# Install git (the php image doesn't have it) which is required by composer
- apt-get update -yqq
- apt-get install git unzip -yqq
- apt-get install php-pear -yqq
# Install composer
- curl -sS https://getcomposer.org/installer | php
- php composer.phar install
# Setup PHPCompatibility for php_codesniffer
- mkdir --parents vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
- cp -R vendor/wimg/php-compatibility/* vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility
stages:
- compatibility_test
- coding_standards
- gulp_build
- gulp_package
# Compatibility Test
PHP 5.2 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.2 src/ --report-full --report-summary --extensions=php
PHP 5.3 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.3 src/ --report-full --report-summary --extensions=php
PHP 5.4 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.4 src/ --report-full --report-summary --extensions=php
PHP 5.5 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.5 src/ --report-full --report-summary --extensions=php
PHP 5.6 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 5.6 src/ --report-full --report-summary --extensions=php
PHP 7.0 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 7.0 src/ --report-full --report-summary --extensions=php
PHP 7.1 Compatibility Test:
  image: php:5.6
  stage: compatibility_test
  script:
  - vendor/bin/phpcs -d date.timezone=GMT --standard=PHPCompatibility --runtime-set testVersion 7.1 src/ --report-full --report-summary --extensions=php
# # Coding Standards Test
PHP Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/ --report-full --report-summary --extensions=php
JS Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/js/ --report-full --report-summary --extensions=js
CSS Coding Standards:
  image: php:5.6
  stage: Coding Standards
  script:
  - vendor/bin/phpcs -s --standard=ruleset.xml src/css/ --report-full --report-summary --extensions=css
# Gulp Build
Gulp:
  image: node:latest
  stage: gulp_build
  script:
  - npm install -g gulp
  - npm install
  - gulp build
  - gulp zip
  artifacts:
    name: "my-build"
    expire_in: 1 week
    paths:
    - "dist/*"    

正如您所见,它有点像野兽,但它确实有效。我有 Gulp 的最后一部分:

# Gulp Build
    Gulp:
      image: node:latest
      stage: gulp_build
      script:
      - npm install -g gulp
      - npm install
      - gulp build
      - gulp zip
      artifacts:
        name: "my-build"
        expire_in: 1 week
        paths:
        - "dist/*"  

目前,在生成工件文件时,它的名称显示为 my-build.zip,这是完美的。但是,直接在其中的文件夹是 dist。有没有办法将 dist 文件夹更改为 my-build?

干杯,

学习

【问题讨论】:

    标签: gulp gitlab gitlab-ci gitlab-ci-runner


    【解决方案1】:

    Gitlab Reddit 的帮助下,我设法解决了我的问题。这就是我所做的:

    Gulp:
        only:
        - master
        - merge-requests
        image: node:latest
        stage: gulp_build
        script:
        - npm install -g gulp
        - npm install
        - gulp build
        - mv -T dist my-build
        - gulp build --premium
        - mv -T dist my-build-premium
        artifacts:
          name: "my-build"
          expire_in: 1 week
          paths:
          - my-build/
          - my-build-premium/
    

    因为它是一个实例,所以我将文件夹重命名为我想要调用的名称,然后将其添加到工件中。我现在也可以在那里进行高级构建,并且只在 Master 和合并请求上使用 Gulp :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 2022-08-13
      • 1970-01-01
      • 1970-01-01
      • 2021-01-07
      相关资源
      最近更新 更多