Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create specifc folder from Gitlab CI artifacts after building with Gulp

I had some geat help here a few weeks back which with gitlab ci as I have never used it before. I have come a decent way and now on my final section to have the output of Gulp to be contained within the artifacts zip.

So Currently my build .yml file looks like this:

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/*"    

As you see its a bit of a beast but it works. The last part I have 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/*"  

Currently when the artifacts file is produced its name is show as my-build.zip which is perfect. However the folder directly within it is dist. Is there a way to change the dist folder to my-build?

Cheers,

Stu

like image 524
snightingale Avatar asked Oct 31 '25 20:10

snightingale


1 Answers

After some help from Gitlab Reddit I managed to resolve my issue. THis is what I did:

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/

As it is an instance, I renamed the folder to what I wanted it to be called and then add it to the artifacts. I could now have a premium build there too along with only using Gulp on Master and merge-requests :)

like image 142
snightingale Avatar answered Nov 02 '25 16:11

snightingale