Setup for Programming Exercises with Bamboo, Bitbucket and Jira¶
This page describes how to set up a programming exercise environment
based on Bamboo, Bitbucket and Jira.
Please note that this setup will create a deployment that is very
similar to the one used in production but has one difference:
In production, the builds are performed within Docker containers that
are created by Bamboo (or its build agents). As we run Bamboo in a
Docker container in this setup, creating new Docker containers within
that container is not recommended (e.g. see this
article). There
are some solution where one can pass the Docker socket to the Bamboo
container, but none of these approaches work quite well here as Bamboo
uses mounted directories that cause issues.
Therefore, a check is included within the BambooBuildPlanService that
ensures that builds are not started in Docker agents if the development
setup is present.
Before you start the docker-compose, check if the bamboo version in the
build.gradle (search for com.atlassian.bamboo:bamboo-specs) is
equal to the bamboo version number in the Dockerfile of bamboo stored in
src/main/docker/bamboo/Dockerfile or src/main/docker/bamboo/swift/Dockerfile.
If the version number is not equal adjust the version number in the Dockerfile.
In case you want to enable Swift programming exercises, you need to change
the specified Dockerfile in the docker-compose file atlassian.yml stored in src/main/docker.
To use the Swift Dockerfile, change the following:
Execute the docker-compose file e.g. with
docker-compose-fsrc/main/docker/atlassian.ymlup-d.
If you notice that the used image didn’t change, append the flag --build.
Error Handling: It can happen that there is an overload with other
docker networks
ERROR:Pooloverlapswithotheroneonthisaddressspace. Use the
command dockernetworkprune to resolve this issue.
Also make sure that docker has enough memory (~ 6GB). To adapt it, go to Preferences->Resources
By default, the Jira instance is reachable under localhost:8081, the
Bamboo instance under localhost:8085 and the Bitbucket instance
under localhost:7990.
Get licenses for Bamboo, Bitbucket and Jira Service Management.
Bamboo: Select Bamboo (Server) and notinstalledyet
Bitbucket: Select Bitbucket (Data Center) and notinstalledyet
Jira: Select Jira Service Management (Data Center) and notinstalledyet
Provide the just created license key during the setup and create an admin user with the same credentials in all 3 applications.
Also, you can select the evaluation/internal/test/dev setups if you are asked.
Follow the additional steps for Jira and Bitbucket.
Jira:
On startup select I'llsetitupmyself
Select Build In Database Connection
Create a sample project
Bitbucket: Do not connect Bitbucket with Jira yet
Execute the shell script atlassian-setup.sh in the
src/main/docker directory (e.g. with
src/main/docker/./atlassian-setup.sh). This script creates
groups, users and disabled application links between the 3 applications.
Make sure that xdg-utils is installed before running the script.
Enable the created application
links
between all 3 application (OAuth Impersonate). The links should open automatically after the shell script
has finished. If not open them manually:
The script has already created users and groups but you need to
manually assign the users into their respective group in Jira. In our
test setup, users 1-5 are students, 6-10 are tutors, 11-15 are
editors and 16-20 are instructors. The usernames are artemis_test_user_{1-20}
and the password is again the username. When you create a course in artemis
you have to manually choose the created groups (students, tutors, editors,
instructors).
Go to Jira → User management → Jira user server → Add application →
Create one application for bitbucket and one for bamboo → add the
IP-address 0.0.0.0/0 to IP Addresses
Go to Bitbucket and Bamboo → User Directories → Add Directories →
Atlassian Crowd → use the URL http://jira:8080 as Server URL →
use the application name and password which you used in the previous
step. Also, you should decrease the synchronisation period (e.g. to 2
minutes). Press synchronise after adding the directory, the users and
groups should now be available.
In Bamboo create a global variable named
SERVER_PLUGIN_SECRET_PASSWORD, the value of this variable will be used
as the secret. The value of this variable should be then stored in
src/main/resources/config/application-artemis.yml as the value of
artemis-authentication-token-value.
Download the
bamboo-server-notification-plugin
and add it to bamboo. Go to Bamboo → Manage apps → Upload app → select
the downloaded .jar file → Upload
Add Maven and JDK:
Go to Bamboo → Server capabilities → Add capabilities menu →
Capability type Executable → select type Maven3.x → insert
Maven3 as executable label → insert /artemis as path.
Add capabilities menu → Capability type JDK → insert JDK16
as JDK label → insert /usr/lib/jvm/java-16-oracle as Java home.
Generate a personal access token
While username and password can still be used as a fallback, this option is already marked as deprecated and will
be removed in the future.
10.1 Personal access token for Bamboo.
Log in as the admin user and go to Bamboo -> Profile (top right corner) -> Personal access tokens -> Create token
Insert the generated token into the file application-artemis.yml in the section continuous-integration:
artemis:continuous-integration:user:<username>password:<password>token:#insert the token here
10.2 Personal access token for Bitbucket.
Log in as the admin user and go to Bitbucket -> View Profile (top right corner) -> Manage account -> Personal access tokens -> Create token
Insert the generated token into the file application-artemis.yml in the section version-control:
artemis:version-control:user:<username>password:<password>token:#insert the token here
Disable XSRF checking
Although XSRF checking is highly recommended, we currently have to disable it as Artemis does not yet support
sending the required headers.
Log in as the admin user go to Bamboo -> Overview -> Security Settings
Edit the settings and disable XSRF checking:
Add a SSH key for the admin user
Artemis can clone/push the repositories during setup and for the online code editor using SSH.
If the SSH key is not present, the username + token will be used as fallback (and all git operations will use HTTP(S) instead of SSH).
If the token is also not present, the username + password will be used as fallback (again, using HTTP(S)).
You first have to create a SSH key (locally), e.g. using ssh-keygen (more information on how to create a SSH key can be found e.g. at ssh.com or at atlassian.com).
The list of supported ciphers can be found at Apache Mina.
It is recommended to use a password to secure the private key, but it is not mandatory.
Please note that the private key file must be named id_rsa, id_dsa, id_ecdsa or id_ed25519, depending on the ciphers used.
You now have to extract the public key and add it to Bitbucket.
Open the public key file (usually called id_rsa.pub (when using RSA)) and copy it’s content (you can also use catid_rsa.pub to show the public key).
Navigate to BITBUCKET-URL/plugins/servlet/ssh/account/keys and add the SSH key by pasting the content of the public key.
<ssh-key-path> is the path to the folder containing the id_rsa file (but without the filename). It will be used in the configuration of Artemis to specify where Artemis should look for the key and store the known_hosts file.
<ssh-private-key-password> is the password used to secure the private key. It is also needed for the configuration of Artemis, but can be omitted if no password was set (e.g. for development environments).
repo-clone-path:./repos/repo-download-clone-path:./repos-download/encryption-password:artemis-encrypt# arbitrary password for encrypting database valuesuser-management:use-external:trueexternal:url:http://localhost:8081user:<jira-admin-user>password:<jira-admin-password>admin-group-name:instructorsinternal-admin:username:artemis_adminpassword:artemis_adminversion-control:url:http://localhost:7990user:<bitbucket-admin-user>password:<bitbucket-admin-password>token:<bitbucket-admin-token>ssh-private-key-folder-path:<ssh-private-key-folder-path>ssh-private-key-password:<ssh-private-key-password>continuous-integration:url:http://localhost:8085user:<bamboo-admin-user>password:<bamboo-admin-password>token:<bamboo-admin-token>vcs-application-link-name:LS1 Bitbucket Serverempty-commit-necessary:trueartemis-authentication-token-value:<artemis-authentication-token-value>
Modify the application-dev.yml
server:port:8080# The port of artemisurl:http://172.20.0.1:8080# needs to be an ip// url:http://docker.for.mac.host.internal:8080# If the above one does not work for mac try this one// url:http://host.docker.internal:8080# If the above one does not work for windows try this one
In addition, you have to start Artemis with the profiles bamboo,
bitbucket and jira so that the correct adapters will be used,
e.g.: