I want to cache some file in branch jobs but not in main branch jobs. Is this possible? I checked https://docs.gitlab.com/ee/ci/caching/, but cant find a way to do this.
Related
How to add .gtilbic.yml to project with many branches which has to be triggered only on commit to master branch.Do i have to edit yml with rule only master branch in every git branch?
Just add your .gitlab-ci.yml file to the default (master) branch. The file can contain a workflow:rules: that makes sure that pipelines are only triggered for commits to the master branch.
workflow:
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
my_job:
script:
- make test # or whatever
Typically, you need this file present in all branches where you want pipelines to run. However, because you only want to run pipelines on the default branch, it's not super important that your branches contain the yaml.
Adding CI for all branches
If you did want to add CI to run on your other branches you could either merge/cherry-pick the change from the default branch into all your branches.
Alternatively, you can use the projects CI/CD settings to specify a custom configuration file that lives in another project. When you apply this setting, it will apply the configuration from the remote project to be triggered for all branches (or other pipeline events).
I would like to ask is there any way I can trigger the gitlab pipeline test manually? For example I just want to play around with the .gitlab-ci.yml script without commiting change to the original .gitlab-ci.yml file.
Right now, anyone that creates a branch in my project and adds a .gitlab-ci.yml file to it, can execute commands on my server using the runner. How can I make it so that only masters or owners can upload CI config files and make changes to them?
I'm using https://gitlab.com/gitlab-org/gitlab-ci-multi-runner running on bash.
The GitLab runner wasn't really designed for this scenario and thus you are unable to do this. What you could do instead is have a new project with just your .gitlab-ci.yml file and configure it so that it pulls the original repository. From there you can do all the other things you want to do with your repository.
I'm running GitLab in a container of Docker but it's okay so far, no problem with that at all. I'm just in doubt about the creation of repositories in projects. I've created my first project in GitLab then after it creation i'd been redirected to a page with some commands to use in terminal. There were three sections, one of them were "Create a repository", i've used those commands and so i could create my repository of my project. However, after this, that page with commands went out and i could just see it again when i created a new project. After all,here goes my question again, is it possible to create two or more repositories into only one project?
I only have time to give a short answer right now, but I hope it helps:
In short: NO
But also: YES, after a fashion
There is a one-to-one correspondence between repositories and projects (which would perhaps better be called repositories as well).
One Solution: Gitlab supports the creation of groups of projects/repos, which can be managed as a project consisting of multiple repos.
Git-based/local Options
If you are interested in git-based solutions to including a repository inside of another repository check out my answer here. If you use either the subtree merge method (at least a variant of it that tracks history) or subrepository method in this answer, your subprojects will appear in your master project in Gitlab, but the master project will also track changes in the subprojects.
Alternative Solution: Create a dummy repo that contains all of your desired repos as subrepos. This master repo will then track all subrepo changes. However; there are a few logistical issues, the .git files for the subrepos will not exist on Gitlab, so you might want a dedicated client with these files to pull the master repo from Gitlab (probably one commit at a time, if you want the subrepo histories to match the main repo history) and update the corresponding local subrepos (these could also be stored independently on GitLab).
I have a Bazaar repository on Host A with multiple branches. This is my main repository.
Until now, I have been doing checkouts on my other machines and committing directly to the main repository. However, now I am consolidating all my work to my laptop and multiple VMs. I need to be working offline regularly. In particular, I need to create/delete/merge branches all while offline.
I was thinking of continuing to have the master on Host A with a clone of the repository on the laptop with each vms doing checkouts of the clone.
Then, when I go offline, I could do bzr unbind on the clone and bzr bind when I am back online.
This failed as soon as I tried to bzr clone since bzr clone only clones a branch(!!!!)
I need some serious help. If Hg would handle this better please let me know (I need Windows support.) However, at this moment I cannot switch from Bazaar as it is too close to some important deadlines.
Thanks in advance!
bzr fundamentally works with one branch / directory (the branch are visible at the file system level), so if you need to clone each branch from your repository (not unlike svn, in a way). Hg, at basic level, works this way too (although you can put several branches in one repository using say named branches).
For DVCS, it is important to distinguish between the following:
Working tree: a versioned set of files (at a given revision)
Branch: a linear set of revisions
Repository: a set of revisions
When you clone locally a directory versioned by bzr, you are copying the repository subset which contains all the revisions in the branch you are cloning, and get the working tree. This assumes you are not asking for a branch wo a working tree nor using a shared repository.
What you want, IIUC, is to clone the full repository with all the branches. There is no 'native' way to do so in bzr I believe, but plugins to help you toward this, like multi-pull and push-repo, to sync multiple branches in one shot.
But I don't understand why that's such a big problem, or the link with working offline: you just clone the branches you want to work on your laptop.