diff --git b/Dockerfile a/Dockerfile new file mode 100644 index 0000000..46e95ea --- /dev/null +++ a/Dockerfile @@ -0,0 +1,10 @@ +FROM jenkins/jenkins:lts-jdk11 +USER root +RUN apt update && \ + apt install -y --no-install-recommends openssh-client vim build-essential gnupg curl cmake libboost* libpaho* ca-certificates apt-transport-https && \ + curl -sSfL https://apt.octopus.com/public.key | apt-key add - && \ + sh -c "echo deb https://apt.octopus.com/ stable main > /etc/apt/sources.list.d/octopus.com.list" && \ + apt update && apt install -y octopuscli +RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers +USER jenkins + diff --git b/README.md a/README.md new file mode 100644 index 0000000..ed5ffa1 --- /dev/null +++ a/README.md @@ -0,0 +1,114 @@ +Explanation on usage: +If ‘Type: ‘ is in front of it, that is a command that should be put on the commandline. + +OSDev Jenkins setup: + +192.168.1.220 (curie) +Fedora 35 server + Go to the directory where the Dockerfile is located (usually /root) as root or import from git. + +Dockerfile: +FROM jenkins/jenkins:lts-jdk11 +USER root +RUN apt update && \ + apt install -y --no-install-recommends openssh-client build-essential gnupg curl cmake libboost* libpaho* ca-certificates apt-transport-https && \ + curl -sSfL https://apt.octopus.com/public.key | apt-key add - && \ + sh -c "echo deb https://apt.octopus.com/ stable main > /etc/apt/sources.list.d/octopus.com.list" && \ + apt update && apt install -y octopuscli +RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers +USER jenkins + + +Setting up the docker image: +Type: docker build . + +copy the hexstring behind “Succesfully built [hexstring]” and past the hexstring behind the following command: + +Type: docker run -d --name=osdev_jenkins -p 8080:8080 -p 50000:50000 --restart=on-failure [hexstring] + +type: docker ps -a +to check if the docker container is made, up and running. + +Log into the docker container: +Type: docker exec -it osdev_jenkins bash + +Type: cd +Type: ssh-keygen (to create the private and public key pair for ssh connectivity) +(choice to put in passphrase, up to you, but need to be remembered for the ssh connectivity of jenkins to other applications) + +copy the content of id_rsa.pub to gitlab user jenkins as public key. +Now to establish a connection and verify the host key, do the following: +Type: cd +Type: git clone git@gitlab.osdev.nl:open_source/mqtt-cpp.git +Type: yes +Type: rm -rf mqtt-cpp + +Backend is now setup. +Last thing to do is the following: +Type: cat /var/jenkins_home/secrets/initialAdminPassword +select and copy the result. + +###################################################################################### +Setting up jenkins frontend: + +go to 192.168.1.220:8080 OR office.osdev.nl:18080 +and follow the next steps to setup jenkins. + +First paste the initialAdminPassword result into the textbox and accept. + +Create an admin user: +name: jenkins +password: *jenkins password* (remember this one!) +email: jenkins@osdev.nl + +Then go for the "Select which plugins to install" option and search for gitlab. +Select it and begin installation. + +Extra plugins to install: +- generic-webhook-trigger (only available AFTER the initial setup, so install first, find the plugin through “manage plugins” later and install) + + +SSH credentials in Jenkins: +create a user “jenkins” and go to “users” "jenkins" “credentials” +Option: SSH connection with private key +Description: gitlab_ssh + +copy the private key from the container. + +How to copy the private file content to jenkins frontend: +docker exec -it osdev_jenkins bash +cd .ssh +cat id_rsa +copy ALL content of the file + +In the gitlab_ssh configuration, find the private key header, select "enter directly" and paste the contents of the private keyfile + + +Add a job: +Description: mqtt-cpp_build +GitLab Connection: +select your gitlab_ssh connection. + +Building steps: +execute shell script + +add the cursive text (without asterixes) to the script frame: + +step 1: + +*cd /var/jenkins_home/workspace/mqtt-cpp_build +rm -rf mqtt-cpp* + + +Now add another buildstep with a shell script: + +step 2: + +*git clone git@gitlab.osdev.nl:open_source/mqtt-cpp.git +cd mqtt-cpp +scripts/setup_submodules -i +mkdir build +cd build +cmake ../ +make* +