In the gitlab-runner, How can I keep the build/? - gitlab-ci

When I start a new pipeline, I don't want to repeat make the directory build/. But the gitlab-runner always remove the build/. How can i keep the build/ ?
Thanks:)

Use a cache: https://docs.gitlab.com/ee/ci/caching/
From the docs:
Use cache for dependencies, like packages you download from the internet. Cache is stored where GitLab Runner is installed and uploaded to S3 if distributed cache is enabled.

Related

How to speed up Gitlab CI build of a c/c++ project with caching

I am building a C/C++ project in the Gitlab CI. Its compilation result is 360 .lo files and the binary (executable) file. It's a slow process, so I want to speed up it. I thought about caching. How to do it? Before, I used caching for npm, Python modules/packages. But now it's C/C++ object files and they are 360 items. How to do it with CI Yaml file? All these object .lo files are located together with source files in the src/ directory.
Caching is the same no matter what objects you're using, so the syntax will be the same for npm and python. In the job that builds your .lo files, add the cache information following the suggestions in the docs (https://docs.gitlab.com/ee/ci/caching/). Then for any other pipelines for that branch (or however you set it up) jobs that depend on the .lo files will download them from the cache instead of creating them.
You could do the following:
Use Ccache
Use the Gitlab cache to cache the Ccache cache folder.
variables:
CCACHE_BASEDIR: $CI_PROJECT_DIR
CCACHE_DIR: $CI_PROJECT_DIR/ccache
before_script:
- ccache --zero-stats
script:
- build your files here
after_script:
- ccache --show-stats
cache:
- key: ccache-$CI_JOB_NAME
paths:
- $CCACHE_DIR
Here is an example .gitlab-ci.yml file using it, and the MR diff where the functionality was added.

Azure Devops Artifacts: disable saving packages from upstream sources

I have a feed for npm packages with npmjs set as upstream source (by default). When you try to install your uploaded custom package with other dependencies, those dependency packages get saved automatically in your feed to save time for future installs. I however do not want it and want my feed to only host my own packages and just download from the upstream source every time an install is made. Is there a way to do this?
What I did instead is make all our packages in a scope and modify the npmrc file to use the azure feed for only that scope so the rest of the packages still gets downloaded from registry.npmjs.org
here's what the .npmrc file would look like
registry=https://registry.npmjs.org/
#customScope:registry=https://ourregistry.org/ourfeed
always-auth=true
Is there a way to do this?
The answer is yes.
If you are creating new feed, you could uncheck the option Upstream sources when you creating the new feed:
If the feed is already created by you, you could delete the upstream sources. Go to the Settings->Upstream sources:
Hope this helps.

Spinnaker configuration loaded as code from gitlab

It is really good that we have spinnaker pipeline as a code from roer and other tools. But is there a way that we will store these pipelines and as well as configurations on gitlab and restore by just fetching the files from gitlab? without really manually inserting the configurations?
You can use "Save Pipelines" stage.
See related commit for details.

GitLab CI use untracked files in repository

I'm evaluating GitLab CI/CD at the moment and trying to get the pipelines working, however am having a simple(?) problem.
I'm trying to automate the build process by automatically updating ISO images. However these ISO images are not tracked by the repository and ignored in a .gitignore file. But this leads to the issue of when I try run make that it can't find the ISO image...
I'm just using a simple .gitlab-ci.yml file:
stages:
- build
build:
stage: build
script:
- make
And when I try running this in the GitLab CI interface, it clones the repository (without the ISO images), and then fails, as there is no rule to that make target (as the ISO images are missing). I have tried moving the files into the "build" directory which GitLab creates, however that gives the error of saying it has failed to remove ...
How do I use the local repository rather than having GitLab clone the repository to a "build" location?
You can't use Gitlab CI with the files that are on your computer, at least you shouldn't. You could do it with an ssh-executor that will login to a machine that stores the iso files (and it should be a server rather than your development machine) or you could have the docker executor pull them from ftp/object store. For testing purposes you can run the builds locally on your machine.

How to restrict runners to a specific branch and lock the .gitlab-ci.yml from changes?

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.