From e85034408ac11c3b41f18b11bb763c37a52419b6 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Wed, 10 Aug 2022 16:38:31 -0700 Subject: [PATCH 1/4] Added the configure instructions --- jenkins/valet-configure-lab.md | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 jenkins/valet-configure-lab.md diff --git a/jenkins/valet-configure-lab.md b/jenkins/valet-configure-lab.md new file mode 100644 index 0000000..6f5b5a0 --- /dev/null +++ b/jenkins/valet-configure-lab.md @@ -0,0 +1,75 @@ +# Configure Valet to work with Jenkins + +In this lab, you will use the Valet `configure` command to set up the required information to communicate with the Jenkins and GitHub instances. The `configure` command can be used for all of the supported providers, in this lab we will be focusing on Jenkins. + +- [Prerequisites](#prerequisites) +- [Configuring Valet](#configuring-valet) +- [Verify Valet Works](#verify-valet-works) +- [Next Lab](#next-lab) + +## Prerequisites + +1. Followed [steps](../Jenkins#readme) to set up your codespace environment and start your Jenkins instanace. + +## Configuring Valet + +1. Login to the Jenkins instance to generate a personal access token: + 1. Click the `PORTS` tab in the codespace terminal window. + 2. In the `PORTS` tab find the row for port 8080. + 3. Hover over the address under the `Local Address` column, and click the globe to "open in browser". + 4. Login to the Jenkins server and generate a Jenkins API token. + - Click the `admin` button located within the top right menu. + - Click on the `configure` gear located on the left hand panel. + - Under the `API token` section, click `Add new Token`. + - Add a defaualt name to your token, then click `Generate`. + - Copy the token that was generated and record token for a later step. +2. Create a GitHub personal access token (PAT). + - 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)` + - Click `Generate new token` -> `Legacy tokens (if present)`. If required, provide your password. + - Select at least these scopes: `read packages` and `workflow`. Optionally, provide a text in the **Note** field and change the expiration. + - Click `Generate token` + - Copy the token somewhere safe and temporary. +3. Run Valet configure commands + - In the codespace terminal window click back to the `TERMINAL` tab. + - Within the terminal, navigate into the Jenkins directory `cd valet` + - Run `gh valet configure` + - Use the down arrow key to highlight `Jenkins`, press the spacebar to select, then hit enter to accept. + - At the prompt enter your GitHub Username and press enter. + - At the GitHub Container Registry prompt enter the GitHub PAT generated in step 3 and press enter + - At the GitHub PAT prompt enter the GitHub PAT generated in step 3 and press enter. + - At the GitHub url prompt enter the GitHub instance url or hit enter to accept the default, if you are using github.com then the default is the right choice. + - At the Jenkins token prompt enter the Jenkins access token from step 2 and press enter. + - 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/18723510/183990474-d0b2559c-d2bf-40d9-ac43-19af53e45329.png) + +## Verify Valet Works + +To verify Valet works we are going to run a `update` and `dry-run` command. We will go further into details about the `dry-run` command in a later lab, but for now we want to get the latest version of Valet and confirm that Valet can perform a dry-run with no errors. + +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 + ``` + + 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. + ![configure-dry-run](https://user-images.githubusercontent.com/18723510/183989794-d51fa29d-b4c0-4074-8402-a55ffcea3a6b.png) + +### Next Lab + +# TODO From 31c07769861ff030632dd5d94b65c972ce661efe Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Wed, 10 Aug 2022 16:46:49 -0700 Subject: [PATCH 2/4] Update valet-configure-lab.md --- jenkins/valet-configure-lab.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jenkins/valet-configure-lab.md b/jenkins/valet-configure-lab.md index 6f5b5a0..ea4989d 100644 --- a/jenkins/valet-configure-lab.md +++ b/jenkins/valet-configure-lab.md @@ -23,6 +23,9 @@ In this lab, you will use the Valet `configure` command to set up the required i - Under the `API token` section, click `Add new Token`. - 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) + 2. Create a GitHub personal access token (PAT). - Navigate to your GitHub `Settings` - click your profile photo and then click `Settings`. - Go to `Developer Settings` @@ -44,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/18723510/183990474-d0b2559c-d2bf-40d9-ac43-19af53e45329.png) +![configure-result](https://user-images.githubusercontent.com/19557880/184041328-ce54ea22-b0cd-4c84-b02c-10ad7b09ad89.png) ## Verify Valet Works @@ -68,8 +71,9 @@ To verify Valet works we are going to run a `update` and `dry-run` command. We ``` 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/18723510/183989794-d51fa29d-b4c0-4074-8402-a55ffcea3a6b.png) + ![configure-dry-run](https://user-images.githubusercontent.com/19557880/184041510-018d7a17-9966-4a0f-af3f-4092dfb90ac0.png) + ### Next Lab -# TODO +TODO From a73bad7543a2dbd9bc23bc5d4544a334ff910839 Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Thu, 11 Aug 2022 15:48:51 -0700 Subject: [PATCH 3/4] typo --- jenkins/valet-configure-lab.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jenkins/valet-configure-lab.md b/jenkins/valet-configure-lab.md index 6f5b5a0..fa5e2e0 100644 --- a/jenkins/valet-configure-lab.md +++ b/jenkins/valet-configure-lab.md @@ -33,8 +33,8 @@ In this lab, you will use the Valet `configure` command to set up the required i - Copy the token somewhere safe and temporary. 3. Run Valet configure commands - In the codespace terminal window click back to the `TERMINAL` tab. - - Within the terminal, navigate into the Jenkins directory `cd valet` - - Run `gh valet configure` + - Within the terminal, ensure you are in the root dirrectory. + - Run `gh valet configure`. - Use the down arrow key to highlight `Jenkins`, press the spacebar to select, then hit enter to accept. - At the prompt enter your GitHub Username and press enter. - At the GitHub Container Registry prompt enter the GitHub PAT generated in step 3 and press enter From c87b6d91c3236cad37af56aa9e0c00e89257d86b Mon Sep 17 00:00:00 2001 From: Begona Guereca Date: Thu, 11 Aug 2022 15:53:36 -0700 Subject: [PATCH 4/4] Updated pics --- jenkins/valet-configure-lab.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jenkins/valet-configure-lab.md b/jenkins/valet-configure-lab.md index 11a25b7..b9456c7 100644 --- a/jenkins/valet-configure-lab.md +++ b/jenkins/valet-configure-lab.md @@ -23,9 +23,9 @@ In this lab, you will use the Valet `configure` command to set up the required i - Under the `API token` section, click `Add new Token`. - 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) - + 2. Create a GitHub personal access token (PAT). - Navigate to your GitHub `Settings` - click your profile photo and then click `Settings`. - Go to `Developer Settings` @@ -71,8 +71,7 @@ To verify Valet works we are going to run a `update` and `dry-run` command. We ``` 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/184041510-018d7a17-9966-4a0f-af3f-4092dfb90ac0.png) - + ![configure-dry-run](https://user-images.githubusercontent.com/19557880/184255620-8e9b120e-5de0-41df-9cb6-c52028de3b0f.png) ### Next Lab