添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

I have a 3 stage .gitlab-ci.yml , based on conda, ie using

image: continuumio/miniconda3:latest

at the top of the yaml. I would like to become more adept at using gitlab-runner exec shell job so I can test the build more readily. Currently, my yaml consists of a before_script, a single job called tests (stage: test), and an after_script. All 3 consist entirely of shell commands. The after_script is:

after_script:
  - conda remove --name owlbear-env --all

The problem I am having is that the after_script does not seem to run when I use exec, thought it does run with the runner. This requires me to manually run this command every time I run the tests locally. Any help would be appreciated.

Is the after_script section nested within the job that you are testing? I did some testing on my own and found that when utilizing the gitlab-runner exec shell <jobname> command the after_script section is ignored unless it’s located within the job you are executing.

This example shows the expected output when running the gitlab-runner exec shell <jobname> command:

job1:
  stage: build
  script: echo "test"
  after_script: 
    - echo "after script"

When configured like this, the after_script section is ignored by the command.

job1:
  stage: build
  script: echo "test"
after_script: 
  - echo "after script"

You could argue that since after_script is supposed to run after every job then the same behavior should be present when using the gitlab-runner exec command. You might want to open a feature proposal for this.

Howdy,

As a follow up to this, it looks like this limitation is documented within the GitLab Runner Commands doc.

Here is the relevant snippet from the “limitations of gitlab runner exec” section related to the after script feature:

global after_script is not supported, only job-level after_script; only commands are taken in consideration, when is hardcoded to always

It looks like they are currently looking at reworking this, so you may want to keep your eye on this issue: Local runner execution MVC.