GitLab CI
一、不同stage间数据传输及不想要每个阶段都进行refetches all changes from the last commit
variables:
GIT_STRATEGY: none
artifacts:
paths:
- path/to/folder/containing/build/files # for example my-lib
[https://stackoverflow.com/questions/43719239/gitlab-deploy-job-fetches-changes-from-git]
二、如何仅对特定分支和标签运行Gitlab CI?
(rules)[https://www.thinbug.com/q/52830653]
[https://stackoverflow.com/questions/67010580/gitlab-ci-yml-jobsbuild-production-config-key-may-not-be-used-with-rules-onl]
(official:choose when to run jobs)[https://docs.gitlab.com/ee/ci/jobs/job_control.html#complex-rules]
三、Gitlab CI配置文件job的script中执行if、for等
(写成一行)[https://blog.csdn.net/k417699481/article/details/110071958]
四、project timeout and runner timeout.
[https://stackoverflow.com/questions/38403681/gitlab-ci-pipeline-stage-timeout]
五、Debug logging
(打印环境变量)
job_name:
variables:
CI_DEBUG_TRACE: "true"
六、Pass an environment variable to another job
[https://docs.gitlab.com/ee/ci/variables/#use-cicd-variables-in-job-scripts]
You can pass environment variables from one job to another job in a later stage. These variables cannot be used as CI/CD variables to configure a pipeline, but they can be used in job scripts.
In the job script, save the variable as a .env file.
Save the .env file as an artifacts:reports:dotenv artifact.
Set a job in a later stage to receive the artifact by using the dependencies or the needs keywords.
The later job can then use the variable in scripts.
七、.gitlab-ci.yml after_script section: how can I tell whether the task succeeded or failed?
值得借鉴,finally我采用的方法为在.sh脚本中对我不想要的状态exit 1(0表正常,>0表异常)
[https://stackoverflow.com/questions/49867981/gitlab-ci-yml-after-script-section-how-can-i-tell-whether-the-task-succeeded-o]
test_job:
stage: test
before_script:
- echo "FAIL" > .job_status
script:
- exit 0
- echo "SUCCESS" > .job_status
after_script:
- echo "$(cat .job_status)"
八、gitlab-runner --debug run
九、before_scripts
我们在 before_scripts 中,通过环境变量拿到了项目所属的组,以及项目名称。GitLab 会在运行任务前,向环境中注入很多环境变量,来表明运行环境以及上下文。所有的环境变量列表可以看文档。
十、GitLabRunner命令
[https://www.cnblogs.com/sanduzxcvbnm/p/13891452.html]
十一、Gitlab pipeline jobs in the same stage are running in parallel
You can find the config.toml file in:
/etc/gitlab-runner/ on *nix systems when GitLab Runner is executed as root (this is also the path for service configuration)
~/.gitlab-runner/ on *nix systems when GitLab Runner is executed as non-root
./ on other systems
config.toml:concurrent = 4(Limits how many jobs can run concurrently.)
[https://stackoverflow.com/questions/46828150/gitlab-pipeline-jobs-in-the-same-stage-are-not-running-in-parallel]
[https://docs.gitlab.com/runner/configuration/advanced-configuration.html]