How to move files from one to second directories on branch during Pipeline run? Gitlab

Viewed 51

I have created Docs folder and it should contain report files. I'm trying to move content from temporary created Allure folder to Docs folder and then copy everything from Docs to public folder to get access to Pages on which that Allure report will be located. I'm doing that process insted of simple copying files from allure folder to public folder to get history about previous runs. Maybe there is some better way to do it ? I'd like to store old reports for some X time (for example for 2 days, to be able to see on ALlure what was wrong is there are some problems) and then delete old ones, not deleting latest which have not reached "deleting point". So, here is my yml file:

stages:
  - testing
  - deploy 

docker_job:
  stage: testing
  tags:
    - docker
  image: atools/chrome-headless:java11-node14-latest 

  before_script:
    - npm ci 
    - npx playwright install
    - npm install allure-commandline --save-dev
  script: #||true
    - npx playwright test
  
    
  after_script:
    - npx allure generate allure-results
  rules:
      - when: always
  allow_failure: true
  artifacts: 
    when: always
    paths:
      - ./allure-report
    expire_in: 1 day 

pages: 
  stage: deploy
  script:
    - mkdir public 
    - mv ./allure-report/* Docs
    - cp -R ./Docs/* public
  artifacts:
    paths:
      - public
  rules:
    - when: always

Everything is going good but it doesn't work - mv ./allure-report/* Docs - cp -R ./Docs/* public are doing nothing or I just can't see any effect. Help me please to correctly solve that problem.

Maybe there is obvious holes in logic, idk, have tried a lot of variants but they all don't work. Can it be done by my way at all?

1 Answers

okay, so I have done it with "logging in" with my git.conf email/name, then using auth token I did a push of these artifacts to Docs folder, looks like:

stages:
    - testing
    - deploy

docker_job:
    stage: testing
    tags:
        - docker
    image: atools/chrome-headless:java11-node14-latest

    before_script:
        - npm ci
        - npx playwright install
        - npm install allure-commandline --save-dev
    script: #||true
        - npx playwright test

    after_script:
        - npx allure generate allure-results
    rules:
        - when: always
    allow_failure: true
    artifacts:
        when: always
        paths:
            - ./allure-report
        expire_in: 15 mins

pages:
    stage: deploy
    script:
        - cp -r -u ./allure-report/* Docs
        - cp -R ./Docs/* public
        - git config --global user.email "mail"
        - git config --global user.name "name"
        - git remote set-url origin https://gitlab-ci-token:${token}@gitlab.com/proj_link
        - git checkout main
        - git add Docs
        - git commit -m "assets"
        - git push
    artifacts:
        paths:
            - public
    rules:
        - when: always


Related