From b321b60c85832516208b6207a60ad5f1e8cf63d3 Mon Sep 17 00:00:00 2001 From: Luke Engle Date: Mon, 19 Sep 2022 17:18:05 -0700 Subject: [PATCH] Initial edits to ADO/gitlab/jenkins --- azure_devops/1-configure.md | 10 ++++++---- azure_devops/3-forecast.md | 2 +- azure_devops/5-custom-transformers.md | 2 +- azure_devops/6-migrate.md | 5 ++--- azure_devops/readme.md | 8 ++++---- gitlab/1-configure.md | 3 ++- gitlab/4-dry-run.md | 10 ++++++++-- gitlab/5-custom-transformers.md | 6 +++--- gitlab/6-migrate.md | 5 ++--- jenkins/1-configure.md | 3 ++- jenkins/5-custom-transformers.md | 4 ++-- jenkins/6-migrate.md | 7 ++----- 12 files changed, 35 insertions(+), 30 deletions(-) diff --git a/azure_devops/1-configure.md b/azure_devops/1-configure.md index 0f0fc00..d7645c7 100644 --- a/azure_devops/1-configure.md +++ b/azure_devops/1-configure.md @@ -14,11 +14,11 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - Click `Personal access tokens`. - Select `+ New Token` - Name your token, select the organization where you want to use the token, and set your token to automatically expire after a set number of days. - - Select the following scopes (you may need to `Show more scopes` to reveal all scopes): + - Select the following scopes (you may need to `Show all scopes` to reveal all scopes): - Agents Pool: `Read` - - Build: `Read & Execute` - - Code: `Read & Write` - - Project and Team: `Read, Write, & Manage` + - Build: `Read & execute` + - Code: `Read & write` + - Project and Team: `Read, write, & manage` - Release: `Read` - Service Connections: `Read` - Task Groups: `Read` @@ -32,6 +32,7 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - In the left panel, click `Developer Settings`. - Click `Personal access tokens` and then `Legacy tokens` (if present). - Click `Generate new token` and then `Generate new legacy token`. You may be required to authenticate with GitHub during this step. + - Name your token in the `Note` field. - Select the following scopes: `workflow` and `read:packages`. - Click `Generate token`. - Copy the generated PAT and save it in a safe location. @@ -40,6 +41,7 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - Select the `TERMINAL` tab from within the codespace terminal. - Run the following command: `gh valet configure`. - Use the down arrow key to highlight `Azure DevOps`, press the spacebar to select, and then press enter to continue. + - At the GitHub handle prompt, enter the GitHub handle used to generate the GitHub PAT in step 2 and press enter. - At the GitHub Container Registry prompt, enter the GitHub PAT generated in step 2 and press enter. - At the GitHub PAT prompt, enter the GitHub PAT generated in step 2 and press enter. - At the GitHub URL prompt, enter the GitHub instance URL or press enter to accept the default value (`https://github.com`). diff --git a/azure_devops/3-forecast.md b/azure_devops/3-forecast.md index 6d0bd7d..8e9ef35 100644 --- a/azure_devops/3-forecast.md +++ b/azure_devops/3-forecast.md @@ -35,7 +35,7 @@ Answer the following questions before running the `forecast` command: ![img](https://user-images.githubusercontent.com/18723510/187690315-6312088d-9888-4c55-9bbf-c6f2687fa547.png) -4. If you inspect the help menu using the `gh valet forecast --help` command, you will see a `--source-file-path` option. You can use this option to perform a `forecast` command using json files that are already present on the filesystem. These labs come bundled with sample json files located [here](./bootstrap/jobs.json). +4. If you inspect the help menu using the `gh valet forecast --help` command, you will see a `--source-file-path` option. You can use this option to perform a `forecast` using json files that are already present on the filesystem. These labs come bundled with sample json files located [here](./bootstrap/jobs.json). ![img](https://user-images.githubusercontent.com/18723510/187692843-623d4bdc-8970-4348-a632-73c8b00a40f8.png) diff --git a/azure_devops/5-custom-transformers.md b/azure_devops/5-custom-transformers.md index 6d2d0d5..24a3c4d 100644 --- a/azure_devops/5-custom-transformers.md +++ b/azure_devops/5-custom-transformers.md @@ -87,7 +87,7 @@ You can use custom transformers to override Valet's default behavior. In this sc - __DotnetCoreCLI@2__ 2. What is the desired Actions syntax to use instead? - - After some research, you have determined that the uploading test results as an artifact will be suitable: + - After some research, you have determined that the following script will provide the desired functionality: ```yaml - run: shopt -s globstar; for f in ./**/*.csproj; do dotnet build $f --configuration ${{ env.BUILDCONFIGURATION }} ; done diff --git a/azure_devops/6-migrate.md b/azure_devops/6-migrate.md index 551f5af..98e4ed2 100644 --- a/azure_devops/6-migrate.md +++ b/azure_devops/6-migrate.md @@ -7,7 +7,6 @@ In this lab, you will use the `migrate` command to convert an Azure DevOps pipel 1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your GitHub Codespaces environment and bootstrap an Azure DevOps project. 2. Completed the [configure lab](./1-configure.md#configuring-credentials). 3. Completed the [dry-run lab](./4-dry-run.md). -4. Completed the [custom transformers lab](./5-custom-transformers.md). ## Performing a migration @@ -21,14 +20,14 @@ Answer the following questions before running a `migrate` command: 2. Where do you want to store the logs? - __tmp/migrate__ 3. What is the URL for the GitHub repository to add the workflow to? - - __this repository__. The URL should follow the pattern with `:owner` and `:repo` replaced with your values. + - __this repository__. The URL should follow the pattern with `:owner` and `:repo` replaced with your values. The command below uses `git remote get-url` to automatically populate these values. ### Steps 1. Run the following `migrate` command in the codespace terminal: ```bash - gh valet migrate azure-devops pipeline --pipeline-id :pipeline_id --target-url https://github.com/:owner/:repo --output-dir tmp/migrate + gh valet migrate azure-devops pipeline --pipeline-id :pipeline_id --target-url $(git remote get-url origin) --output-dir ./tmp/migrate ``` 2. The command will write the URL to the pull request that was created when the command succeeds. diff --git a/azure_devops/readme.md b/azure_devops/readme.md index ca3805e..6b30624 100644 --- a/azure_devops/readme.md +++ b/azure_devops/readme.md @@ -45,11 +45,11 @@ These steps **must** be completed prior to starting other labs. - Click `Personal access tokens`. - Select `+ New Token` - Name your token, select the organization where you want to use the token, and set your token to automatically expire after a set number of days. - - Select the following scopes (you may need to `Show more scopes` to reveal all scopes): + - Select the following scopes (you may need to `Show all scopes` at the bottom of the page to reveal all scopes): - Agents Pool: `Read` - - Build: `Read & Execute` - - Code: `Read & Write` - - Project and Team: `Read, Write, & Manage` + - Build: `Read & execute` + - Code: `Read & write` + - Project and Team: `Read, write, & manage` - Release: `Read` - Service Connections: `Read` - Task Groups: `Read` diff --git a/gitlab/1-configure.md b/gitlab/1-configure.md index 6a00435..4df7fd6 100644 --- a/gitlab/1-configure.md +++ b/gitlab/1-configure.md @@ -31,6 +31,7 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - In the left panel, click `Developer Settings`. - Click `Personal access tokens` and then `Legacy tokens` (if present). - Click `Generate new token` and then `Generate new legacy token`. You may be required to authenticate with GitHub during this step. + - Name your token in the `Note` field. - Select the following scopes: `workflow` and `read:packages`. - Click `Generate token`. - Copy the generated PAT and save it in a safe location. @@ -39,7 +40,7 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - Select the `TERMINAL` tab from within the codespace terminal window. - Run the following command: `gh valet configure`. - Use the down arrow key to highlight `GitLab CI`, press the spacebar to select, and then press enter to continue. - - At the prompt, enter your GitHub username and press enter. + - At the GitHub handle prompt, enter the GitHub handle used to generate the GitHub PAT in step 2 and press enter. - At the GitHub Container Registry prompt, enter the GitHub PAT generated in step 4 and press enter. - At the GitHub PAT prompt, enter the GitHub PAT generated in step 4 and press enter. - At the GitHub URL prompt, enter the GitHub instance URL or press enter to accept the default value (`https://github.com`). diff --git a/gitlab/4-dry-run.md b/gitlab/4-dry-run.md index 169e925..597e9a3 100644 --- a/gitlab/4-dry-run.md +++ b/gitlab/4-dry-run.md @@ -211,7 +211,13 @@ include: - local: /config/test.gitlab-ci.yml ``` -The output of the `dry-run` command can be seen below: +Run the following command from the root directory: + +```bash +gh valet dry-run gitlab --output-dir tmp/dry-run --namespace valet --project included-files-example +``` + +The output of the command above can be seen below: ```yaml name: valet/included-files-example @@ -246,7 +252,7 @@ jobs: - run: echo "this is from a local file" ``` -It's important to note that Valet converted this into a single workflow without templates. This is because of fundamental differences in how GitLab templates and GitHub Actions templates (i.e. Reusable Workflows and Composite Actions) function in regards to job ordering. Unfortunately, elements of reusability will be sacrificed in order for the converted pipelines to function the same. It is likely that the output of Valet could be refactored to use [reusable workflow](https://docs.github.com/en/actions/using-workflows/reusing-workflows) at a later date. +It's important to note that Valet converted this into a single workflow without templates. This is because of fundamental differences in how GitLab templates and GitHub Actions templates (i.e. Reusable Workflows and Composite Actions) function in regards to job ordering. Unfortunately, elements of reusability will be sacrificed in order for the converted pipelines to function the same. It is likely that the output of Valet could be refactored to use [reusable workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows) at a later date. As an added challenge, try constructing and running the `dry-run` command yourself. Hint, you should only have to change the project name. diff --git a/gitlab/5-custom-transformers.md b/gitlab/5-custom-transformers.md index 5413ed4..6d34709 100644 --- a/gitlab/5-custom-transformers.md +++ b/gitlab/5-custom-transformers.md @@ -9,7 +9,7 @@ In this lab you will build upon the `dry-run` command to override Valet's defaul ## Prerequisites -1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your GitHub Codespaces environment and start you GitLab server. +1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your GitHub Codespaces environment and start your GitLab server. 2. Completed the [configure lab](./1-configure.md#configuring-credentials). 3. Completed the [dry-run lab](./4-dry-run.md). @@ -63,7 +63,7 @@ The converted workflow above contains an `artifacts.terraform` step that was not - __artifacts.terraform__ 2. What is the desired Actions syntax to use instead? - - After some research, you have determined that the following bash script will provide similar functionality: + - After some research, you have determined that the following GitHub Action will provide similar functionality: ```yaml - uses: actions/upload-artifact@v3 @@ -82,7 +82,7 @@ Next, you will define a `transform` method for the `artifacts.terraform` identif ```ruby transform "artifacts.terraform" do |item| { - uses: "actions/upload-artifact@v2", + uses: "actions/upload-artifact@v3", with: { path: item } diff --git a/gitlab/6-migrate.md b/gitlab/6-migrate.md index 3dcd734..3bac8ff 100644 --- a/gitlab/6-migrate.md +++ b/gitlab/6-migrate.md @@ -7,7 +7,6 @@ In this lab, you will use the `migrate` command to convert a GitLab pipeline and 1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your GitHub Codespaces environment and start a GitLab server. 2. Completed the [configure lab](./1-configure.md#configuring-credentials). 3. Completed the [dry-run lab](./4-dry-run.md). -4. Completed the [custom transformers lab](./5-custom-transformers.md). ## Performing a migration @@ -20,14 +19,14 @@ Answer the following questions before running a `migrate` command: 3. Where do you want to store the logs? - __tmp/migrate__ 4. What is the URL for the GitHub repository to add the workflow to? - - __this repository__. The URL should should follow the pattern with `:owner` and `:repo` replaced with your values. + - __this repository__. The URL should should follow the pattern with `:owner` and `:repo` replaced with your values. The command below uses `git remote get-url` to automatically populate these values. ### Steps 1. Run the following `migrate` command in the codespace terminal: ```bash - gh valet migrate gitlab --target-url https://github.com/:owner/:repo --output-dir tmp/migrate --namespace valet --project rails-example + gh valet migrate gitlab --target-url $(git remote get-url origin) --output-dir ./tmp/migrate --namespace valet --project rails-example ``` 2. The command will write the URL to the pull request that was created when the command succeeds. diff --git a/jenkins/1-configure.md b/jenkins/1-configure.md index 8128140..71ede17 100644 --- a/jenkins/1-configure.md +++ b/jenkins/1-configure.md @@ -32,11 +32,12 @@ You will need to complete all of the setup instructions [here](./readme.md#confi - Select the `TERMINAL` tab from within the codespace terminal window. - Run the following command: `gh valet configure`. - Use the down arrow key to highlight `Jenkins`, press the spacebar to select, and then press enter to continue. - - At the prompt, enter your GitHub username and press enter. + - At the GitHub handle prompt, enter the GitHub username used to generate the GitHub PAT in step 3 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 press enter to accept the default value (`https://github.com`). - At the Jenkins token prompt, enter the Jenkins access token from step 2 and press enter. + - At the Jenkins username prompt, enter `admin` 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, press enter to accept the default value. diff --git a/jenkins/5-custom-transformers.md b/jenkins/5-custom-transformers.md index 281c4a2..c4628e0 100644 --- a/jenkins/5-custom-transformers.md +++ b/jenkins/5-custom-transformers.md @@ -75,7 +75,7 @@ _Note_: You can refer to the previous [lab](./4-dry-run.md) to learn about the f ## Custom transformers for an unknown step -The converted workflow above contains a `sleep` step was not automatically converted. Answer the following questions before writing a custom transformer: +The converted workflow above contains a `sleep` step that was not automatically converted. Answer the following questions before writing a custom transformer: 1. What is the "identifier" of the step to customize? - __sleep__. The identifier will be the key of a key value pair within the step of a Jenkinsfile. @@ -198,7 +198,7 @@ Now you can perform another `dry-run` command with the `--custom-transformers` C + - uses: actions/upload-artifact@v3 + with: + name: junit-artifact -+ path: path/to/artifact/world.txt ++ path: "**/target/*.xml" ``` ## Custom transformers for environment variables diff --git a/jenkins/6-migrate.md b/jenkins/6-migrate.md index 773b929..04b8348 100644 --- a/jenkins/6-migrate.md +++ b/jenkins/6-migrate.md @@ -7,7 +7,6 @@ In this lab, you will use the `migrate` command to convert a Jenkins pipeline an 1. Followed the steps [here](./readme.md#configure-your-codespace) to set up your GitHub Codespaces environment and start a Jenkins server. 2. Completed the [configure lab](./1-configure.md#configuring-credentials). 3. Completed the [dry-run lab](./4-dry-run.md). -4. Completed the [custom transformers lab](./5-custom-transformers.md). ## Performing a migration @@ -18,14 +17,14 @@ Answer the following questions before running a `migrate` command: 2. Where do you want to store the logs? - __tmp/migrate__ 3. What is the URL for the GitHub repository to add the workflow to? - - __this repository__. The URL should follow the pattern with `:owner` and `:repo` replaced with your values. + - __this repository__. The URL should follow the pattern with `:owner` and `:repo` replaced with your values. The command below uses `git remote get-url` to automatically populate these values. ### Steps 1. Run the following `migrate` command in your codespace terminal: ```bash - gh valet migrate jenkins --target-url https://github.com/:owner/:repo --output-dir tmp/migrate --source-url http://localhost:8080/job/monas_dev_work/job/monas_freestyle + gh valet migrate jenkins --target-url $(git remote get-url origin) --output-dir ./tmp/migrate --source-url http://localhost:8080/job/monas_dev_work/job/monas_freestyle ``` 2. The command will write the URL to the pull request that was created when the command succeeds. @@ -44,8 +43,6 @@ The first thing we should notice about the pull request is that there is a list ![img](https://user-images.githubusercontent.com/19557880/186784161-b7882ac4-ac99-4462-b69f-f49b9202527b.png) -Next, review the workflow you are adding by clicking on the `Files changed` tab. This is where you double check that everything looks good. If it didn't, you could push commits with the required changes, prior to merging. - Next, you can inspect the "Files changed" in this pull request and see the converted workflow that is being added. Any additional changes or code reviews that were needed should be done in this pull request. Finally, you can merge the pull request once your review has completed. You can then view the workflow running by selecting the "Actions" menu in the top navigation bar in GitHub.