dnacenter-jenkins-tutorial

所属分类:构建工具
开发工具:Python
文件大小:0KB
下载次数:0
上传日期:2022-12-09 05:53:58
上 传 者sh-1993
说明:  Cisco DNA中心-Jenkins集成教程
(Cisco DNA Center - Jenkins Integration tutorial)

文件列表:
.DS_Store (6148, 2021-11-08)
.vscode/ (0, 2021-11-08)
.vscode/settings.json (43, 2021-11-08)
Jenkinsfile (1246, 2021-11-08)
LICENSE (1077, 2021-11-08)
cli_templates.py (4952, 2021-11-08)
config/ (0, 2021-11-08)
config/cli_templates.yaml (648, 2021-11-08)
config/sites.yaml (60, 2021-11-08)
images/ (0, 2021-11-08)
images/.DS_Store (6148, 2021-11-08)
images/add-credentials.png (149008, 2021-11-08)
images/blue-ocean.png (158650, 2021-11-08)
images/build-with-parameters.png (237105, 2021-11-08)
images/credentials.png (133578, 2021-11-08)
images/github-project.png (37493, 2021-11-08)
images/global-domain.png (142182, 2021-11-08)
images/new-item.png (48799, 2021-11-08)
images/new-pipeline.png (418859, 2021-11-08)
images/parameter.png (62647, 2021-11-08)
poetry.lock (9924, 2021-11-08)
pyproject.toml (352, 2021-11-08)
requirements.txt (231, 2021-11-08)
sites.py (2691, 2021-11-08)
templates/ (0, 2021-11-08)
templates/template.j2 (37, 2021-11-08)
templates/template_with_params.j2 (108, 2021-11-08)

# Cisco DNA Center - Jenkins integration This repository is an example of how you can integrate Cisco DNA Center with [Jenkins](https://www.jenkins.io/). ## Goal The goal is to demonstrate how you can leverage the Jenkins pipeline features to deploy configuration templates using Cisco DNA Center APIs. ## Environment For this demo, the following software or platforms are used: 1. Cisco DNA Center version 2.2.2.3 2. Jenkins 2.303.1 3. Debian GNU/Linux 11 4. Docker 5. Github ## Prerequisites - Install Jenkins on the Debian server. Follow [this tutorial](https://www.howtoforge.com/how-to-install-jenkins-on-debian-11/) - Install Docker on the Debian server. Check [this information](https://docs.docker.com/engine/install/debian/#install-from-a-package) ## BlueOcean To improve the experience using Jenkins, it is highly recommended that the BlueOcean plugin is installed. The installation can be done directly from Jenkins, **Dashboard** -> **Manage Jenkins** -> **Manage Plugins**, there you can select the BlueOcean and scroll down to ask Jenkins to install the plugin. ![Blue Ocean Pluging](./images/blue-ocean.png) ## Files The solution files are: - **Jenkinsfile**: The Jenkins pipeline configuration file. This is the file used to define the steps Jenkins is going to follow during the pipeline process. - **requirements.txt**: Python requirements file use to install the needed libraries in the docker environment. - **cli_templates.py**: Python script that reads the `config/cli_templates.yaml` file and deploys configuration templates stored in `templates` using Cisco DNA Center API. - **sites.py**: Python script that reads the `config/sites.yaml` file and creates a site in Cisco DNA Center. ## Process 1. Once Jenkins and Docker are installed in the Debian server, you will need to clone this repository and upload it to your own Github repository to do testing. 2. Create a Github personal access token to integrate Jenkins with Github 3. Create a Jenkins project with your Github repository information 4. Define environment variables within Jenkins to use during the pipeline process. 5. Trigger a pipeline execution ## Github steps ### Clone repository Clone the repository in your local machine. `git clone https://github.com/cisco-en-programmability/dnacenter-jenkins-tutorial.git` ### Create your Github repository Follow [this link](https://docs.github.com/en/get-started/quickstart/create-a-repo) to create the repository. However, **skip** the step to initialize the repository with a README. Once you create the repository, move to the cloned repository directory and execute the following: `git remote set-url origin https://` This step migrates the URL of the central repository to your repository. Push the repository to the new one: `git push` ### Create a Github Personal Token The Github personal token is used to integrate Jenkins with Github. Github does not support to use your username and password to login from another process, nor is it secure to do it. You can create the Github Personal Token following this [documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). You will need to store the token because it will be used to configure the Jenkins pipeline. ## Jenkins Configuration steps ### Credentials Before creating the new pipeline, you have to create the credentials to access your Github repository. Go to **Dashboard** -> **Manage Jenkins** -> **Manage Credentials** ![Credentials](./images/credentials.png) You have the select the **Global Domain** and there the **Add credentials** option. ![Global Domain Credentials](./images/global-domain.png) You have to choose the **Username and password** kind where the username will be your GitHub username and the password will be your GitHub personal token created in the last step. ![Add Credentials](./images/add-credentials.png) Enter something you will remember for the Description field, like **GitHub DNAC Creds**. ### New pipeline Create a new pipeline **Dashboard** -> **New Item** -> **Pipeline**. ![New Item](./images/new-item.png) You can choose the name of the pipeline, it does not have to be the same as the Github repository. For the purposes of this tutorial, the pipeline will be called: **DNAC Jenkins Test**. Make sure to select **Pipeline** as the type of item option. ![New Pipeline](./images/new-pipeline.png) ### Pipeline configuration The Pipeline configuration has multiple tabs: #### General - **GitHub Project**: Enter your repository URL - **This project is parametrized**: Add the following parameters: | Parameter | Type | Value | | ------------------- | -------- | ----------------------------------- | | DNA_CENTER_USERNAME | String | DNA Center Username | | DNA_CENTER_PASSWORD | Password | DNA Center Password | | DNA_CENTER_DEBUG | String | False | | DNA_CENTER_BASE_URL | String | DNA Center IP or FQDN with https:// | | DNA_CENTER_VERIFY | String | False | #### Build triggers For this tutorial, we do not have to select an option here because we will trigger the pipeline execution manually, but here is where you can decide when do you want the pipeline to be executed. #### Advanced Project options Select the **Pipeline script from SCM** option and configure it with the following information: | Parameter | Type | | ---------------- | ----------------------------------------- | | SCM | Git | | Repository URL | Enter your repository URL | | Credentials | Enter your previously created credentials | | Branch Specifier | \*/main | | Script Path | Jenkinsfile | Save the configuration. ## Jenkins Build Steps Once you are done with the configuration, you should be able to access the pipeline and trigger the build with the **Build with parameters** button. ![Build with parameters](./images/build-with-parameters.png) There you can trigger the pipeline manually. If you installed the BlueOcean plugin, you should have a button on the left that will take you to more friendly pipeline interface.

近期下载者

相关文件


收藏者