Jenkins Master setup - griddynamics/mpl GitHub Wiki
Jenkins Master setup
To test the MPL & examples you need a properly configured Jenkins Master, here is described how to run it using docker.
Basic installation
- You need installed docker on your system (Mac & Linux should be fine, but Win users will suffer as usual).
- Run the jenkins master using shell command (Linux & Mac):
docker run --name jenkins -it --rm -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/.jenkins_docker:/var/jenkins_home -v ${HOME}:/home/user jenkins/jenkins:lts-alpine
- Jenkins master will be started and will show you a message about initial setup required with temp password for admin user, copy it.
- Go to [http://localhost:8080/] and enter admin password.
- Choose "Install suggested plugins" - it will take some time.
- Now, when plugins are installed, continue as admin, leave default url and continue to the default dashboard.
Dynamic agents
I do recommend to use dynamic docker agents even if it's a local jenkins for testing to make sure you creating really portable pipelines.
- Allow jenkins to use the docker daemon to create agents, execute the next command in terminal:
docker exec -it -u 0 jenkins chmod o+rw /var/run/docker.sock
- We need an additional plugin to manage docker jenkins agents: Go to "Manage Jenkins" --> "Manage Plugins" --> tab "Available", search for "Docker" plugin and install it without restart.
- Now we need to configure the docker cloud plugin:
- Click on "Build Executor Status" in the dashboard, click on "Configure Clouds", click on "Add new Cloud" and select "Docker" - it will add new cloud provider.
- Let's configure the added cloud: click on "Docker Cloud Details" button and set Docker Host URI to "unix:///var/run/docker.sock".
- Now click on "Test Connection" button - it should show the docker daemon version and API version.
- Set the "Enabled" flag.
- Now we need to add a template to the Docker provider:
- Click on "Docker Agent Templates" button
- Click on "Add Docker Template" button
- Set the values:
- Labels: "LS"
- Enabled: True
- Name: "jnlp"
- Docker Image: "jenkins/jnlp-slave:alpine"
- Remote File System Root: /home/jenkins
- Click on "Container Settings" button and add "Mounts": I'm usually mount my Work directory to have access to my local git repositories:
type=bind,src=<HOME dir on host system>/Work,dst=/home/user/Work
- Click "Save" button and the docker cloud plugin is configured
MPL library setup
To run demos we need a configured MPL jenkins shared library.
- Go to "Manage Jenkins" --> "Configure System" and find "Global Pipeline Libraries" section and click "Add" button to add a new one.
- Set the values:
- Name: "mpl"
- Default Version: "master"
- Select "Modern SCM" in "Retrieval method" section
- And select "Source Code Management":
- If you have local clone of MPL - use "Git" and set "Project Repository", for example "/home/user/Work/git/mpl"
- If you want to use github - select "GitHub" and configure it accordingly.