Bookings are managed via eventbrite. If you're interested in a particular date and it's already full, please add your name to the waiting list, we'll notify you if a place becomes available.
@@ -6,22 +6,72 @@ Get your account ready for you to use it.
### Introduction ###
Before you can make use of your gitlab account, you need to upload your SSH key to it. Here's how:
Before you can make use of your gitlab account, there are a few things you should do to make it more useful:
- Click on your username or avatar in the top right-hand corner, and select **Settings**
- create a Personal Access Token (mandatory if you want to do the exercises)
- upload your SSH key (optional)
- configure email notifications (optional)
### Create a Personal Access Token ###
This is a way to access gitlab.ebi.ac.uk if you have two-factor authentication turned on, which you should have by default. With 2FA, you can't use your normal password to authenticate a `git push`, instead you need to use a **Personal Access Token**, which you create in the gitlab website.
Click on your username or avatar in the top right-hand corner, and select **Settings**
Make a note of the access token you see on the next screen, keep it somewhere safe. This is almost as powerful as your password, and should be treated with the same level of caution. If you lose it, you won't be able to recover it from the web interface, but you can create another one easily enough.
N.B. It's good hygiene to create separate tokens for separate purposes. That way you can revoke the access token for one use-case, if needed, without affecting others. Don't share tokens either, the token belongs to _you_, not to individual projects, so giving it to someone gives them access to all your projects, not just to any one project.
### Upload your SSH key (optional!) ###
This is useful to help you avoid having to type in your password every time you commit code to your projects. However, SSH access to gitlab.ebi.ac.uk is only available via the EBI network, not from outside, so its usefulness is a bit limited. Also, you will need to know how to use an SSH agent to cache your password. Google has a number of tutorials on that.
Click on your username or avatar in the top right-hand corner, and select **Settings**
Click on **SSH Keys** on the navigation bar on the left
Elsewhere on the page you'll see that you can choose at the Group or Project level which set of notification presets you want for that group or project.
That's it, you don't need to save the options, they're saved automatically.
### Conclusion ###
You should now be able to push to your gitlab repositories without having to log in with every commit, exactly as with github and other hosting services.
You will get notification by email for any interesting events in your repositories, and can tune that as needed to control the noise.
### Best Practices ###
Ideally you should use a different SSH key for every service (gitlab, github, bitbucket, whatever) that requires you to register with a key. This limits the damage if ever one of those keys is compromised.
Likewise, use different access tokens for different purposes, with only the level of access required.
Elsewhere on the page you'll see that you can choose at the Group or Project level which set of notification presets you want for that group or project.
That's it, you don't need to save the options, they're saved automatically.
- Tell git to cache your password for one hour. This saves you typing it in all the time whenever you make a push to the server. This is only needed when you use the **https** URL, with the SSH URL you can use an ssh-agent to cache the connection information instead. However, the SSH URL isn't accessible outside the EBI network, so we use the https URL for portability here:
@@ -44,7 +52,7 @@ Then go to the **CI/CD** -> **Pipelines** tab and watch the progress of your pip
The build fails because the code which is uploaded points to my personal project, which only I have access to.
To fix this, edit the **.gitlab-ci.yml** file, change the **APPLICATION** name to the name of your project, and the **REGISTRY_USER** to your gitlab username. Save the file, commit it to git, and push it to the server again.
To fix this, edit the **.gitlab-ci.yml** file, change the **APPLICATION** name to the name of your project, and the **REGISTRY_USER** to your gitlab username. Save the file, commit it to git, and push it to the server again. This time, you only need a ```git push```, with no extra arguments.
Go to the **CI/CD** -> **Pipelines** tab again, this time it should succeed.
@@ -38,7 +38,9 @@ Now that you're logged into the registry you can even push images there by hand,
### Deploy tokens ###
If you want to run this docker image in a batch script, or a web service, you won't want to have to log into the registry on every machine you use, or every time it gets rebooted. Instead, if you only want to _use_ the images, but not to _upload_ them from the coomand line, you want a way to have read-only access to the registry. Gitlab provides **deploy-tokens** for that purpose, follow the link on the Registry page to learn more about them.
If you want to run this docker image in a batch script, or a web service, you won't want to have to log into the registry on every machine you use, or every time it gets rebooted. Instead, if you only want to _use_ the images, but not to _upload_ them from the coomand line, you want a way to have read-only access to the registry. Gitlab provides **deploy-tokens** for that purpose, which are basically the same as the access token you've already created in the first exercise. For running batch jobs, you should create another, giving it only **read_registry** access, nothing else. You can then safely publish this anywhere you like, the worst people can do with it is to download your images.
You'll need to make a note of the expiry date of your deploy tokens, and set a reminder to create a new one well in advance if you're running in a production environment. Alternatively, if your containers are fit for public release, you can push them to a public service like dockerhub instead.
What happens if you use a git branch, instead of a tag? The CI/CD pipeline will still fire, and will know the branch name, so it uses that in the docker image tag. However, since your **.gitlab-ci.yml** file only runs the **test** stage for git _tags_ and not for git _branches_, you will only get a two-stage pipeline.
Can you modify the YAML file so it runs for branches too? [Check the documentation](https://docs.gitlab.com/ee/ci/yaml/#onlyexcept-basic) for help.
If you're on a branch, and you use a tag too, what do you think gitlab will do? Try it and find out.
### Conclusion ###
You now know how to control the activities in a build when using git tags, and how to use those tags to automatically tag the docker image with the same name.