Below is my YML file structure. I want the following up stages to be run without reinitializing the git repository. The git repository should only be initialized during the first stage, which is the build stage.
variables:
GIT_STRATEGY: fetch
stages:
- build
- run_test
- run_test2
build_job:
variables:
test_env: "test"
stage: build
script:
- "powershell -File ./Scripts/BuildSolution.ps1"
only:
refs:
- TDD-G2
run_test:
variables:
test_env: "test"
stage: run_test
script:
- "powershell -File ./Project1/scripts/RunSelenium.ps1"
artifacts:
when: always
paths:
- ./Project1/TestResults
run_test2:
variables:
test_env: "test"
stage: run_test2
script:
- "powershell -File ./Project2/scripts/RunSelenium.ps1"
artifacts:
when: always
paths:
- ./Project2/TestResults
Answers 2 : of UNDO Reinitialized existing Git repository Made a mistake. You can fix the existing local commit by staging all the fixes and then running git commit --ammed. Then, overwrite the remote branch by git push --force origin.
GitLab and GitLab Runner perform a shallow clone by default.
To enable or disable GitLab CI/CD Pipelines in your project: Navigate to Settings > General > Visibility, project features, permissions. Expand the Repository section. Enable or disable the Pipelines toggle as required.
You can set the GIT_STRATEGY used for getting recent application code, either in the global variables section or the variables section for individual jobs. If left unspecified, the default from project settings will be used. There are three possible values: clone , fetch , and none .
The git repository should only be initialized during the first stage, which is the build stage. Show activity on this post. I was facing quite similar problem and where I had three stage's build, test and deploy.
GitLab CI/CD supports numerous configuration options: Schedule pipelines to run as often as you need. Define a custom path for the CI/CD configuration file. Configure jobs for using Git submodules. Using SSH keys in your CI pipelines. Trigger pipelines through the API. Design a pipeline structure for running a pipeline in merge requests.
If you are using an external CI/CD server like Jenkins or Drone CI, it is advised to disable GitLab CI/CD in order to not have any conflicts with the commits status API. GitLab CI/CD is exposed via the /pipelines and /jobs pages of a project. Disabling GitLab CI/CD in a project does not delete any previous jobs.
If you ever want to reuse the old repository and its history, just rename the folder .git and then use the commands for a new start, either depending on the situation, if you have a remote repo your are starting from or if your local files are the starting point.
I was facing quite similar problem and where I had three stage's build, test and deploy. In deploy stage i wanted to create a tag something like But I was facing a strange issue where even after deleting the tag from remote (Note: i was working alone on this project) the pipeline was failing continuously saying the tag already exists. But after some time the same job completed successfully.
To fix this I set the strategy to clone
(Explained below) only for deploy(Git repository was reinitializing again here) job but for build and test it is fetch(default option). As
variables:
GIT_STRATEGY: clone
For GitLab:
Git strategy
Introduced in GitLab Runner 8.9.
By default, GitLab is configured to use the fetch Git strategy, which is recommended for large repositories. This strategy reduces the amount of data to transfer and does not really impact the operations that you might do on a repository from CI.
There are two options. Using:
Detail Read is here and here
Hope it help to someone who came to this issue.
You could use the variable GIT_CLEAN_FLAGS
to instruct the gitlab-runner to call git clean
in a constrained way. For example, by specifying none
, you could disable calling git clean
alltogether, so files produced by the previous stage won't be deleted.
run_test:
variables:
test_env: "test"
GIT_CLEAN_FLAGS: none
https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-clean-flags https://docs.gitlab.com/ee/ci/large_repositories/#git-clean-flags
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With