1

I have a python script that I am trying to run as part of gitlab pages deployment of a jekyll site. My site has blog posts that have various tags, and the python script generates the .md files for the tag pages. The script works perfectly fine when I just manually run it in an IDE, however I want it to be part of the gitlab ci deployment process

here is what my gitlab-ci.yml setup looks like:

run:
  image: python:latest
  script:
  - python tag_generator.py
  artifacts:
    paths:
    - public
  only:
  - master

pages:
  image: ruby:2.3
  stage: deploy
  script:
    - bundle install
    - bundle exec jekyll build -d public
  artifacts:
    paths:
    - public
  only:
  - master

however, it doesn't actually create the files that it's supposed to create, here is the output from the job "run":

...
Cloning repository...
Cloning into '/builds/username/projectname'...
Checking out 4c8a47fe as master...
Skipping Git submodules setup
$ python tag_generator.py
Tags generated, count 23
Uploading artifacts...
WARNING: public: no matching files                 
ERROR: No files to upload                          
Job succeeded

the script reads out "tags generated, count ___" once it's executed, so it is running, however the files that it's supposed to create aren't being created/uploaded into the right directory. there is a /tag directory in the root project folder, that is where they are supposed to go.

I realize that the issue must have something to do with the public folder, however when I don't have

artifacts:
    paths:
    - public

it still doesn't create the files in the /tag directory, so it doesn't work whether I have -public or not, and I don't know what the problem is.

leucotic
  • 61
  • 6

1 Answers1

2

I FIGURED IT OUT!

the "build" for the project isn't made in the repo, gitlab clones the repo into another place, so I had to change the artifact path for the python job so that it's in the cloned "build" location, like so:

run:
  image: python:latest
  stage: test
  before_script:
  - python -V               # Print out python version for debugging
  - pip install virtualenv
  script:
  - python tag_generator.py
  artifacts:
    paths:
    - /builds/username/projectname/tag
  only:
  - master
leucotic
  • 61
  • 6