I want to use one gitlab-runner
to make two similar, but not exact same builds.
In the git
repository, I have several branches: prod, test, dev.
Is it possible to use only one runner to build on different paths?
For example:
/home/gitlab-runner/builds/860ee11a/0/projectname
- prod/home/gitlab-runner/builds/860ee11a/1/projectname
- test/home/gitlab-runner/builds/860ee11a/2/projectname
- devIf so, how do you do that?
Feature branching Git workflow Every feature gets its own branch when developers commit to this workflow. Rather than commit directly to the main branch, developers create a branch, make changes, and then merge it into main. Ideally, a branch should have a lifespan of a few hours.
Step 1 − Login to your GitLab account and go to your project under Projects section. Step 2 − To create a branch, click on the Branches option under the Repository section and click on the New branch button. Step 3 − In the New branch screen, enter the name for branch and click on the Create branch button.
Change the default branch name for a project Sign in to GitLab with at least the Maintainer role. In the left navigation menu, go to Settings > Repository. Expand Default branch, and select a new default branch.
If you have access project A and B, you can use multi-project pipelines. You trigger a pipeline in project A from project B. In project A, you clone project B and run your script.
Yes, you can do that.
You can use this logic:
image: <image> # choose your image (ryby, python, node, php etc)
# add cache for speeding up builds
cache:
paths:
- <cache-folder>/ # the name will need to be set according to your project
before_script:
- <your command> # here you set the commands you want to run for every commit
- <your command>
# add a job called 'build' -> to run your builds
build:
stage: build # this will define the stage
script:
- <your scripts> # choose the script you want to run first
only:
- build # the 'build' job will affect only 'build' branch
# add a job called 'test' -> to run your tests
test:
stage: test # this will define the stage
script:
- <your scripts> # choose the script similar to the deployment
except:
- master # the 'test' job will affect all branches expect 'master'
# the 'deploy' job will deploy and build your project
deploy:
stage: deploy
script:
- <your scripts> # your deployment script
artifacts:
paths:
- <folder> # generate files resulting from your builds for you to download
only:
- master # this job will affect only the 'master' branch
You can also use when
to run a job when
another succeeds or fails.
Examples:
Docs:
Hope to have helped!
Yes this is the default behavior. Whenever you push to the repo (regardless of the branch), an active runner will go ahead and run your build. Log and artifacts are stored independently.
In your .gitlab-ci.yml you can take different actions based on the branch or tag name. See http://doc.gitlab.com/ce/ci/yaml/README.html for more info and look for the only and except key words.
Finally you can create triggers that use the API. See http://doc.gitlab.com/ce/ci/triggers/README.html
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