From f39ff0ef217b21e15919f2abe679e646c79b1f4b Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Thu, 25 Aug 2022 16:28:07 -0700 Subject: [PATCH] Edits + updated Monas pipeline --- azure_devops/readme.md | 77 +++++++++++-------- azure_devops/valet-audit-lab.md | 14 +++- azure_devops/valet-dry-run-lab.md | 25 ++++-- .../jobs/monas_freestyle/config.xml | 12 ++- jenkins/readme.md | 23 ++++-- jenkins/valet-audit-lab.md | 6 +- jenkins/valet-configure-lab.md | 26 +++---- jenkins/valet-custom-transformers-lab.md | 10 +-- jenkins/valet-dry-run-lab.md | 10 +-- jenkins/valet-forecast-lab.md | 12 ++- jenkins/valet-migrate-lab.md | 16 ++-- 11 files changed, 144 insertions(+), 87 deletions(-) diff --git a/azure_devops/readme.md b/azure_devops/readme.md index ba0c2e5..46aee0a 100644 --- a/azure_devops/readme.md +++ b/azure_devops/readme.md @@ -15,30 +15,31 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you 1. Verify you are in your own Repository created from the landing page [Valet Labs](https://github.com/valet-customers/labs). ## Prerequisites + 1. Azure DevOps organization. Please identify or create an Azure DevOps organization to use: [Click to create an Azure DevOps Org](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/create-organization?toc=%2Fazure%2Fdevops%2Fget-started%2Ftoc.json&bc=%2Fazure%2Fdevops%2Fget-started%2Fbreadcrumb%2Ftoc.json&view=azure-devops) - Note and store the Azure DevOp sorganization name for later. - Note and store the user name you use for your Azure DevOps Organization. It will be an email address. -2. Azure DevOps Project. The default project name for this lab is `ValetBootstrap` There is an Action workflow that will create and populate the Azure DevOps project. No need to create it yourself. Note: The project has to be unique in the Azure DevOps organization. If you already have a project name `ValetBootstrap` please pick a different unique project name. +2. Azure DevOps Project. The default project name for this lab is `ValetBootstrap` There is an Action workflow that will create and populate the Azure DevOps project. No need to create it yourself. Note: The project has to be unique in the Azure DevOps organization. If you already have a project name `ValetBootstrap` please pick a different unique project name. - Note and store the Azure DevOps project name for later. 3. Create an Azure DevOps personal access token with the following scopes: - - To do so, navigate to Sign in to your organization `https://dev.azure.com/{yourorganization}`. - - Click your `Account management` icon - - Click `user settings` - - Click `Personal access tokens`. - - Select `+ New Token` - - Name your token, select the organization where you want to use the token, and then set your token to automatically expire after a set number of days. - - Select the following scopes (Click `Show more scopes` if you don't see all of the below): - - Agents Pool: `Read` - - Build: `Read & Execute` - - Code: `Read & Write` - - Project and Team: `Read, Write, & Manage` - - Release: `Read` - - Service Connections: `Read` - - Task Groups: `Read` - - Variable Groups: `Read` - - Click `Create` - - Copy the PAT somewhere safe and temporary. -4. Create a GitHub personal access token. + - To do so, navigate to Sign in to your organization `https://dev.azure.com/{yourorganization}`. + - Click your `Account management` icon + - Click `user settings` + - Click `Personal access tokens`. + - Select `+ New Token` + - Name your token, select the organization where you want to use the token, and then set your token to automatically expire after a set number of days. + - Select the following scopes (Click `Show more scopes` if you don't see all of the below): + - Agents Pool: `Read` + - Build: `Read & Execute` + - Code: `Read & Write` + - Project and Team: `Read, Write, & Manage` + - Release: `Read` + - Service Connections: `Read` + - Task Groups: `Read` + - Variable Groups: `Read` + - Click `Create` + - Copy the PAT somewhere safe and temporary. +4. Create a GitHub personal access token. - To do so, navigate to your GitHub `Settings` - click your profile photo and then click `Settings`. - Go to `Developer Settings` - Go to `Personal Access Tokens` -> `Legacy tokens (if present)` @@ -48,6 +49,7 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you - Copy the PAT somewhere safe and temporary. ## Codespace secrets + Please add the following Codespace secrets. - `VALET_GHCR_PASSWORD`: Add `VALET_GHCR_PASSWORD` as the `Name` and the GitHub personal access token created above as the value. @@ -66,6 +68,7 @@ Steps to create the Codespace secrets. Complete for secret noted above: - Click `Add Secret` ## Action secrets + Please add the following Action secrets. - `AZURE_DEVOPS_ACCESS_TOKEN`: Add `AZURE_DEVOPS_ACCESS_TOKEN` as the `Name` and the Azure DevOps personal access token created above as the value. @@ -83,19 +86,20 @@ Steps to create the Actions secret. Complete for secret noted above: ## Azure DevOps project creation Run the Actions workflow: + - CLick the `Actions` tab - Select the `Valet Bootstrap for Azure DevOps` action - Click `Run Workflow` - Input the Azure DevOps Organization name identified above - Input the Azure DevOps user name of the user that created the Azure DevOps PAT above. This will be an email address - Accept the default Azure DevOps project name or change it to one of your preference - - NOTE: The default project name is `ValetBootstrap`. This must be unique in your Azure DevOps Organization. If not, please choose a unique name. + - NOTE: The default project name is `ValetBootstrap`. This must be unique in your Azure DevOps Organization. If not, please choose a unique name. - Click `Run Workflow` - Verify the workflow completed successfully. If the workflow did not run successfully you will see a detailed error message. ### Example ### -![runaction](https://user-images.githubusercontent.com/26442605/167679930-9bdf6f4f-2e94-4145-aed3-8ee3e8e91d90.png) +![runaction](https://user-images.githubusercontent.com/26442605/167679930-9bdf6f4f-2e94-4145-aed3-8ee3e8e91d90.png) ## Use Valet with a codespace @@ -105,29 +109,34 @@ Run the Actions workflow: - Click `Create codespaces on main` to create the codespace. If you are in another branch then the `main` branch, the codespace will button will have the current branch specified. - Wait a couple minutes, then verify that the codespace starts up. Once it is fully booted up, the termininal should be present. 2. Verify Valet CLI is installed and working. More information on the [GitHub Valet CLI extension](https://github.com/github/gh-valet) - - Verify Valet CLI is installed and working - - Run `gh valet version` in the Visual Studio Code terminal and verify the output looks like the below image. Note the valet version will be different than below as the latest version gets pulled down. - - If `gh valet version` did not produce a similar image with a version please follow these instructions [Troubleshoot GH Valet extension](#troubleshoot-gh-valet-extension) - - Start using Valet by following along with the [Labs for Azure DevOps](#labs-for-azure-devops) - + - Verify Valet CLI is installed and working + - Run `gh valet version` in the Visual Studio Code terminal and verify the output looks like the below image. Note the valet version will be different than below as the latest version gets pulled down. + - If `gh valet version` did not produce a similar image with a version please follow these instructions [Troubleshoot GH Valet extension](#troubleshoot-gh-valet-extension) + - Start using Valet by following along with the [Labs for Azure DevOps](#labs-for-azure-devops) + ### Example ### + ![gh-valet-version](https://user-images.githubusercontent.com/26442605/170106559-e69e669f-a1f6-4c2c-8998-3f089b899704.png) ## Labs for Azure DevOps + Perform the following labs to test-drive Valet + - [Audit Azure DevOps pipelines using the Valet audit command](valet-audit-lab.md) -- [Dry run the migration of an Azure DevOps pipeline to GitHub Actions](valet-dry-run-lab.md) +- [Dry-run the migration of an Azure DevOps pipeline to GitHub Actions](valet-dry-run-lab.md) - [Migrate an Azure DevOps pipeline to GitHub Actions](valet-migrate-lab.md) - [Migrate an Azure DevOps pipeline to GitHub Actions with a custom transformer](valet-migrate-custom-lab.md) - [Forecast: Valet forecast lab](valet-forecast-lab.md) ## Troubleshoot GH Valet extension + Manually Install the GitHub CLI Valet extension. More information on the [GitHub Valet CLI extension](https://github.com/github/gh-valet) -- Verify you are in the Visual Studio Code terminal -- Run this command to install the GitHub Valet extension -- `gh extension install github/gh-valet` -- Verify the result of the install is: `✓ Installed extension github/gh-valet` -- If you get a similiar error to the following, click the link to authorize the token + +- Verify you are in the Visual Studio Code terminal +- Run this command to install the GitHub Valet extension +- `gh extension install github/gh-valet` +- Verify the result of the install is: `✓ Installed extension github/gh-valet` +- If you get a similiar error to the following, click the link to authorize the token ![linktolcickauth](https://user-images.githubusercontent.com/26442605/169588015-9414404f-82b6-4d0f-89d4-5f0e6941b029.png) - - Restart Codespace after clicking the link -- Verify Valet CLI is installed and working + - Restart Codespace after clicking the link +- Verify Valet CLI is installed and working diff --git a/azure_devops/valet-audit-lab.md b/azure_devops/valet-audit-lab.md index 40aa2dc..e7a6887 100644 --- a/azure_devops/valet-audit-lab.md +++ b/azure_devops/valet-audit-lab.md @@ -1,4 +1,5 @@ # Audit Azure DevOps pipelines using the Valet audit command + In this lab, you will use Valet to `audit` an Azure DevOps organization. The `audit` command can be used to scan a CI server and output a summary of the current pipelines. This summary can then be used to plan the timeline and effort required to migrate to GitHub Actions. - [Prerequisites](#prerequisites) @@ -13,24 +14,29 @@ In this lab, you will use Valet to `audit` an Azure DevOps organization. The `au 2. Create or start a codespace in this repository (if not started) ## Perform an audit + You will use the codespace preconfigured in this repository to perform the audit. -1. Navigate to the codespace Visual Studio Code terminal +1. Navigate to the codespace Visual Studio Code terminal 2. Verify you are in the `valet` directory 3. Now, from the `valet` folder in your repository, run Valet to verify your Azure DevOps configuration: ``` gh valet audit azure-devops --output-dir audit ``` + ### Example + ![valet-audit-1](https://user-images.githubusercontent.com/26442605/169615028-696dad13-ff83-41a7-b475-0ab8c0bbcd65.png) 4. Valet displays green log files to indicate a successful audit ### Example + ![valet-audit-2](https://user-images.githubusercontent.com/26442605/169615218-a8a3199d-a436-4d70-8c1e-17a61b089eb6.png) ## View audit output + The audit summary, logs, Azure DevOps yml, and GitHub yml should all be located in the `valet` folder. 1. Under the `valet` folder find the `audit_summary.md` @@ -39,14 +45,18 @@ The audit summary, logs, Azure DevOps yml, and GitHub yml should all be located 4. Review the file. ### Example + ![valet-audit-3](https://user-images.githubusercontent.com/26442605/169615428-26f7a962-2064-46d0-8206-ea930109b252.png) ## Review the pipelines + The `audit` command grabs the yml, classic, and release pipelines from Azure DevOps and converts them to GitHub Actions. ### Example + View the source yml and the proposed GitHub yml ![valet-audit-4](https://user-images.githubusercontent.com/26442605/169615630-8d700081-c631-4b2a-ab1c-e52503f7838f.png) ### Next Lab -[Dry run the migration of an Azure DevOps pipeline to GitHub Actions](valet-dry-run-lab.md) + +[Dry-run the migration of an Azure DevOps pipeline to GitHub Actions](valet-dry-run-lab.md) diff --git a/azure_devops/valet-dry-run-lab.md b/azure_devops/valet-dry-run-lab.md index 36ae851..3e57857 100644 --- a/azure_devops/valet-dry-run-lab.md +++ b/azure_devops/valet-dry-run-lab.md @@ -1,9 +1,10 @@ -# Dry run the migration of an Azure DevOps pipeline to GitHub Actions +# Dryrun the migration of an Azure DevOps pipeline to GitHub Actions + In this lab, you will use the `valet dry-run` command to convert an Azure DevOps pipeline to it's equivalent GitHub Actions workflow and write the workflow to your local filesystem. - [Prerequisites](#prerequisites) - [Identify the Azure DevOps pipeline ID to use](#identify-the-azure-devops-pipeline-id-to-use) -- [Perform a dry run](#perform-a-dry-run) +- [Perform a dry-run](#perform-a-dry-run) - [View dry-run output](#view-dry-run-output) - [Next Lab](#next-lab) @@ -14,39 +15,49 @@ In this lab, you will use the `valet dry-run` command to convert an Azure DevOps 3. You have completed the [Valet audit lab](valet-audit-lab.md). ## Identify the Azure DevOps pipeline ID to use -You will need a pipeline ID to perform the dry run + +You will need a pipeline ID to perform the dry-run + 1. Go to the `valet/ValetBootstrap/pipelines` folder 2. Open the `valet/ValetBootstrap/pipelines/valet-pipeline1.config.json` file 3. Look for the `$.web.href` link 4. At the end of the link is the pipeline ID. Copy or note the ID. ### Example + ![valet-dr-5](https://user-images.githubusercontent.com/26442605/169616920-7c407adc-0c4e-4104-9046-d1d2ecdd6edf.png) -## Perform a dry run -You will use the codespace preconfigured in this repository to perform the dry run. +## Perform a dry-run -1. Navigate to the codespace Visual Studio Code terminal +You will use the codespace preconfigured in this repository to perform the dry-run. + +1. Navigate to the codespace Visual Studio Code terminal 2. Verify you are in the `valet` directory ``` gh valet dry-run azure-devops pipeline --pipeline-id PIPELINE-ID --output-dir dry-run ``` -3. Now, from the `valet` folder in your repository, run `gh valet dry-run` to see the output: + +3. Now, from the `valet` folder in your repository, run `gh valet dry-run` to see the output: ### Example + ![valet-dr-1](https://user-images.githubusercontent.com/26442605/169616149-46c2d743-47fe-4061-a48a-7f21442624cb.png) 4. Valet will create a folder called `dry-runs` under the `valet` folder that shows what will be migrated. ### Example + ![valet-dr-2](https://user-images.githubusercontent.com/26442605/169616265-176a19fd-3071-44fc-bff7-866a172afc57.png) ## View dry-run output + The dry-run output will show you the GitHub Actions yml that will be migrated to GitHub. ### Example + ![valet-dr-3](https://user-images.githubusercontent.com/26442605/169616486-fd5512fa-0761-45fe-a252-5b2ef0926a04.png) ### Next Lab + [Migrate an Azure DevOps pipeline to GitHub Actions](valet-migrate-lab.md) diff --git a/jenkins/bootstrap/pipelines/monas_dev_work/jobs/monas_freestyle/config.xml b/jenkins/bootstrap/pipelines/monas_dev_work/jobs/monas_freestyle/config.xml index 5ff13df..6a0acb0 100644 --- a/jenkins/bootstrap/pipelines/monas_dev_work/jobs/monas_freestyle/config.xml +++ b/jenkins/bootstrap/pipelines/monas_dev_work/jobs/monas_freestyle/config.xml @@ -1,5 +1,6 @@ + false @@ -19,5 +20,14 @@ echo "Hope you are enjoying the lab!" - + + + + + ${secret.test} + EXPRESSION_VAR + + + + \ No newline at end of file diff --git a/jenkins/readme.md b/jenkins/readme.md index 613244b..88b1893 100644 --- a/jenkins/readme.md +++ b/jenkins/readme.md @@ -22,17 +22,28 @@ This lab bootstraps a Valet environment using GitHub Codespaces and enables you - Wait a couple minutes, then verify that the codespace starts up. Once it is fully booted up, the termininal should be present. 2. Verify Valet CLI is installed and working. More information on the [GitHub Valet CLI extension](https://github.com/github/gh-valet) - Verify Valet CLI is installed and working - - Run `gh valet version` in the Visual Studio Code terminal and verify the output looks like the below image. Note the valet version will be different than below as the latest version gets pulled down. + - Run the following command in the Visual Studio Code terminal: + + ``` + gh valet version + ``` + + - Verify the output looks like the below image. Note the valet version will be different than below as the latest version gets pulled down. - If `gh valet version` did not produce a similar image with a version please follow these instructions [Troubleshoot GH Valet extension](#troubleshoot-gh-valet-extension) -Screen Shot 2022-08-10 at 1 45 20 PM +Screen Shot 2022-08-10 at 1 45 20 PM ## Bootstrap Jenkins 1. Run the Jenkins setup script. This script will setup Jenkins and ensure it is ready to use. In general, this script should be run first if you are starting a new codespace or restarting an existing one. - Navigate to the terminal within your Codespace. -- Run `source jenkins/bootstrap/setup.sh` to kick off the creation of your Jenkins instance. +- Run the following command to kick off the creation of your Jenkins instance: + + ``` + source jenkins/bootstrap/setup.sh + ``` + - After a couple seconds, a pop-up box should appear with a link to the forwarded URL for your Jenkins instance. - You can also access the forwarded URL by going to the `Ports` tab in your terminal. Right click on the URL listed under the `Local Address` and clicking the `Open in Browser` tab. - Once you have navigated to the url, the following default credentials have been assigned: @@ -48,7 +59,7 @@ Perform the following labs to test-drive Valet - [Configure Valet to work with Jenkins](valet-configure-lab.md#configure-valet-to-work-with-jenkins) - [Audit Jenkins using the Valet audit command](valet-audit-lab.md#audit-jenkins-pipelines-using-the-valet-audit-command) -- [Dry run the migration of an Jenkins pipeline to GitHub Actions](valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions) +- [Dry-run the migration of an Jenkins pipeline to GitHub Actions](valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions) - [Using Custom Transformers in a dry-run](valet-custom-transformers-lab.md#using-custom-transformers-in-a-dry-run) - [Migrate an Jenkins Project to GitHub Actions](valet-migrate-lab.md#migrate-a-jenkins-project-to-github-actions) - [Forecast the usage of a Jenkins namespace](valet-forecast-lab.md#forecast-the-runner-usage-of-a-jenkins-instance) @@ -65,7 +76,7 @@ Manually Install the GitHub CLI Valet extension. More information on the [GitHub - Restart Codespace after clicking the link - Verify Valet CLI is installed and working by running `gh valet version` -![linktolcickauth](https://user-images.githubusercontent.com/26442605/169588015-9414404f-82b6-4d0f-89d4-5f0e6941b029.png) + ![linktolcickauth](https://user-images.githubusercontent.com/26442605/169588015-9414404f-82b6-4d0f-89d4-5f0e6941b029.png) ## Troubleshooting Jenkins @@ -74,4 +85,4 @@ Manually Install the GitHub CLI Valet extension. More information on the [GitHub - If you see the `jenkins:valet` container, but it has a red stopped symbol next to it ▢, right click on the container and click on `start`, the container should begin running again. - If the container does not start even after trying to manually start it, right click on the `jenkins:valet` container and click the `remove` button. Next continue by following all the #bootstrap-jenkins instructions again. -Screen Shot 2022-08-09 at 3 06 46 PM + Screen Shot 2022-08-09 at 3 06 46 PM diff --git a/jenkins/valet-audit-lab.md b/jenkins/valet-audit-lab.md index cad80e1..86a0d1f 100644 --- a/jenkins/valet-audit-lab.md +++ b/jenkins/valet-audit-lab.md @@ -14,8 +14,8 @@ By the end of this lab you will have performed an audit on the demo Jenkins inst ## Prerequisites -1. Follow all steps [here](../jenkins#readme) to set up your environment. -2. Follow all steps [here](../jenkins#valet-configure-lab) to configure Valet. +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. +2. Completed the [configure lab](../jenkins/valet-configure-lab.md#configure-valet-to-work-with-jenkins) to configure the Valet CLI. ## Perform an audit @@ -121,4 +121,4 @@ In addition, you’ll see a file that shows the raw JSON data that we pull from ### Next Lab -[Dry run the migration of a Jenkins pipeline to GitHub Actions](valet-dry-run-lab.md) +[Dry-run the migration of a Jenkins pipeline to GitHub Actions](valet-dry-run-lab.md) diff --git a/jenkins/valet-configure-lab.md b/jenkins/valet-configure-lab.md index 9a028ae..2ce300f 100644 --- a/jenkins/valet-configure-lab.md +++ b/jenkins/valet-configure-lab.md @@ -9,7 +9,7 @@ In this lab, you will use the Valet `configure` command to set up the required i ## Prerequisites -1. Followed [steps](../jenkins/readme.md) to set up your codespace environment and start your Jenkins instanace. +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. ## Configuring Valet @@ -24,7 +24,7 @@ In this lab, you will use the Valet `configure` command to set up the required i - Add a defaualt name to your token, then click `Generate`. - Copy the token that was generated and record token for a later step. -![configure-result](https://user-images.githubusercontent.com/19557880/184041667-d06cb7f2-a885-474e-b728-7567314aeaf3.png) + ![configure-result](https://user-images.githubusercontent.com/19557880/184041667-d06cb7f2-a885-474e-b728-7567314aeaf3.png) 2. Create a GitHub personal access token (PAT). - Navigate to your GitHub `Settings` - click your profile photo and then click `Settings`. @@ -47,7 +47,7 @@ In this lab, you will use the Valet `configure` command to set up the required i - At the Jenkins url prompt enter `http://localhost:8080/` and press enter. - At the Personal access token to fetch source code in GitHub prompt, if any of your Jenkins pipelines have source code in a GitHub repository enter the GitHub PAT that would have acess to these files. 4. If all went well you should see a similar output in your terminal: -![configure-result](https://user-images.githubusercontent.com/19557880/184041328-ce54ea22-b0cd-4c84-b02c-10ad7b09ad89.png) + ![configure-result](https://user-images.githubusercontent.com/19557880/184041328-ce54ea22-b0cd-4c84-b02c-10ad7b09ad89.png) ## Verify Valet Works @@ -56,23 +56,23 @@ To verify Valet works we are going to run a `update` and `dry-run` command. We 1. In the codespace terminal update Valet by running `gh valet update` 2. In the terminal you should see a confirmation that it logged into the GitHub Container Registry and pulled the latest version. - ``` - Login Succeeded - latest: Pulling from valet-customers/valet-cli - Digest: sha256:a7d00dee8a37e25da59daeed44b1543f476b00fa2c41c47f48deeaf34a215bbb - Status: Image is up to date for ghcr.io/valet-customers/valet-cli:latest - ghcr.io/valet-customers/valet-cli:latest - ``` + ``` + Login Succeeded + latest: Pulling from valet-customers/valet-cli + Digest: sha256:a7d00dee8a37e25da59daeed44b1543f476b00fa2c41c47f48deeaf34a215bbb + Status: Image is up to date for ghcr.io/valet-customers/valet-cli:latest + ghcr.io/valet-customers/valet-cli:latest + ``` - 3. Next, lets run the dry-run command in the codespaces terminal, to verify we can talk to Jenkins +3. Next, lets run the dry-run command in the codespaces terminal, to verify we can talk to Jenkins ``` gh valet dry-run jenkins --source-url https://localhost:8080/job/test_pipeline/ --output-dir ./tmp/dry-run-lab ``` - 4. In the terminal you should see the command was successful, if not it is a good time to practice the configure command again and make sure the access tokens values are correct and were generated with the correct permissions. +4. In the terminal you should see the command was successful, if not it is a good time to practice the configure command again and make sure the access tokens values are correct and were generated with the correct permissions. ![configure-dry-run](https://user-images.githubusercontent.com/19557880/184255620-8e9b120e-5de0-41df-9cb6-c52028de3b0f.png) ### Next Lab -[Dry-run Jenkins Pipelines to a GitHub Action Workflow](../jenkins/valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions) +[Audit Jenkins using the Valet audit command](valet-audit-lab.md#audit-jenkins-pipelines-using-the-valet-audit-command) diff --git a/jenkins/valet-custom-transformers-lab.md b/jenkins/valet-custom-transformers-lab.md index bddb276..79c9a69 100644 --- a/jenkins/valet-custom-transformers-lab.md +++ b/jenkins/valet-custom-transformers-lab.md @@ -19,9 +19,9 @@ These customizations will be present in many of our company's pipelines and an a ## Prerequisites -1. Followed [steps](../jenkins#readme) to set up your codespace environment. -2. Completed the [configure lab](../jenkins/valet-configure-lab.md) -3. Completed the [dry-run lab](../jenkins/valet-dry-run-lab.md) +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. +2. Completed the [configure lab](../jenkins/valet-configure-lab.md#configure-valet-to-work-with-jenkins) to configure the Valet CLI. +3. Completed the [dry-run lab](../jenkins/valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions). ## Perform a dry-run @@ -98,7 +98,7 @@ jobs: -Go back to the previous lab [Dry-run Jenkins Pipeline](../jenkins/valet-dry-run-lab.md) if you need a review of the details of the dry-run. +Go back to the previous lab [dry-run Jenkins pipeline](../jenkins/valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions) if you need a review of the details of the dry-run. ## Custom transformers for an unknown step @@ -185,7 +185,7 @@ gh valet dry-run jenkins --source-url http://localhost:8080/job/test_pipeline -o You should see something like the following outputted into the terminal: -Screen Shot 2022-08-17 at 10 25 53 AM +Screen Shot 2022-08-17 at 10 25 53 AM Now that we know the structure of the incoming JSON blob for `item` we can access the file path programmatically. diff --git a/jenkins/valet-dry-run-lab.md b/jenkins/valet-dry-run-lab.md index 82b7d69..a1f902b 100644 --- a/jenkins/valet-dry-run-lab.md +++ b/jenkins/valet-dry-run-lab.md @@ -1,18 +1,18 @@ -# Dry run the migration of a Jenkins pipeline to GitHub Actions +# Dry-run the migration of a Jenkins pipeline to GitHub Actions In this lab, you will use the Valet `dry-run` command to convert a Jenkins pipeline to its equivalent GitHub Actions workflow. The end result of this command will be the actions workflow written to your local filesystem. - [Prerequisites](#prerequisites) -- [Perform a dry run](#perform-a-dry-run) +- [Perform a dry-run](#perform-a-dry-run) - [Review dry-run output](#review-dry-run-output) - [Next Lab](#next-lab) ## Prerequisites -1. Followed [steps](../Jenkins#readme) to set up your codespace environment. -2. Completed the [configure lab](../Jenkins/valet-configure-lab.md) -3. Completed the [audit lab](../Jenkins/valet-audit-lab.md) +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. +2. Completed the [configure lab](../jenkins/valet-configure-lab.md#configure-valet-to-work-with-jenkins) to configure the Valet CLI. +3. Completed the [audit lab](../Jenkins/valet-audit-lab.md#audit-jenkins-pipelines-using-the-valet-audit-command). ## Perform a dry-run diff --git a/jenkins/valet-forecast-lab.md b/jenkins/valet-forecast-lab.md index ea29f9c..d43f526 100644 --- a/jenkins/valet-forecast-lab.md +++ b/jenkins/valet-forecast-lab.md @@ -11,19 +11,23 @@ In this lab we will use the `forecast` command to forecast potential GitHub Acti ## Prerequisites -1. Followed [steps](../jenkins#readme) to set up your codespace environment. -2. Ran the setup script in the terminal to make sure the Jenkins instance is ready. -3. Completed the [configure lab](../Jenkins/valet-configure-lab.md). +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. +2. Completed the [configure lab](../jenkins/valet-configure-lab.md#configure-valet-to-work-with-jenkins) to configure the Valet CLI. ## Prepare for forecast Before we can run the forecast we need to answer a few questions so we can construct the correct command. 1. Do we want to forecast the entire Jenkins instance, or just a single folder? + - In this example we will be auditing the entire Jenkins instance, but in the future if you wanted to configure a specific folder to be audited add the `-f ` flag to the forecast command. + 2. What is the date we want to start forecasting from? + - __2022-08-02__. This date is before the time the data was populated in the Jenkins server running in these labs. This value defaults to the date one week ago, however, you should ensure a date is used that will capture enough data to get a representative view of typical usage. + 3. Where do we want to store the results? + - `./tmp/forecast_reports`. This can be any valid path on the system, but for simplicity it is recommend to use a directory in the root of the workspace. ## Perform a forecast @@ -44,7 +48,7 @@ Open the forecast report and review the calculated metrics. - From the codespace explorer pane find `./tmp/forecast_reports/forecast_report.md` and right-click, and select __Open Preview__. -![forecast_explorer](https://user-images.githubusercontent.com/18723510/185234641-948a551b-316f-4cce-9e7d-4c078ae11a04.png) + ![forecast_explorer](https://user-images.githubusercontent.com/18723510/185234641-948a551b-316f-4cce-9e7d-4c078ae11a04.png) - The file should be similar to this. diff --git a/jenkins/valet-migrate-lab.md b/jenkins/valet-migrate-lab.md index cfcf640..b8d2a80 100644 --- a/jenkins/valet-migrate-lab.md +++ b/jenkins/valet-migrate-lab.md @@ -13,10 +13,10 @@ The pull request will contain a checklist of `Manual Tasks` if required. These t ## Prerequisites -1. Followed [steps](../jenkins/readme.md) to set up your codespace environment. -2. Completed the [configure lab](../jenkins/valet-configure-lab.md) -3. Completed the [dry-run lab](../jenkins/valet-dry-run-lab.md) -4. Completed the [dry-run lab with custom transformer](../jenkins/valet-custom-transformers-lab.md) +1. Followed [steps](../jenkins/readme.md#valet-labs-for-jenkins) to set up your codespace environment and start your Jenkins instanace. +2. Completed the [configure lab](../jenkins/valet-configure-lab.md#configure-valet-to-work-with-jenkins) to configure the Valet CLI. +3. Completed the [dry-run lab](../jenkins/valet-dry-run-lab.md#dry-run-the-migration-of-a-jenkins-pipeline-to-github-actions). +4. Completed the [dry-run lab with custom transformer](../jenkins/valet-custom-transformers-lab.md#using-custom-transformers-in-a-dry-run). ## Preparing for migration @@ -31,9 +31,9 @@ Before running the command we need to collect some information: 1. Run `migrate` command using the information collected above, make sure to update the `--target-url` value with the information from step 4. -```bash -gh valet migrate jenkins --target-url https://github.com/GITHUB-ORG-USERNAME-HERE/GITHUB-REPO-NAME-HERE --output-dir ./tmp/migrate --source-url http://localhost:8080/job/monas_dev_work/job/monas_freestyle -``` + ```bash + gh valet migrate jenkins --target-url https://github.com/GITHUB-ORG-USERNAME-HERE/GITHUB-REPO-NAME-HERE --output-dir ./tmp/migrate --source-url http://localhost:8080/job/monas_dev_work/job/monas_freestyle + ``` 2. Valet will create a pull request directly in the target GitHub repository. 3. Open the pull request by clicking the green pull request link in the output of the migrate command, if you have trouble clicking it you can always copy and paste the url in your browser. @@ -43,6 +43,8 @@ gh valet migrate jenkins --target-url https://github.com/GITHUB-ORG-USERNAME-HER - Lets first look at the `Conversation` tab of the PR. It tells us we have a manual task to perform before the GitHub Actions workflow is functional. We need to add a secret. We can use the GitHub [documentation](https://docs.github.com/en/actions/security-guides/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for secrets and add a `actions` secret for `EXPRESSION_FIRST_VAR` with any value. + ![Manual steps](https://user-images.githubusercontent.com/19557880/186784161-b7882ac4-ac99-4462-b69f-f49b9202527b.png) + - Next, lets review the workflow we are adding by clicking on `Files changed` tab. This is where you would double check everything looks good. If it didn't you could push commits with the required changes, prior to merging. - Now our review is completed we want to go back to the `Conversation` tab and click `Merge pull request`