From 336916330f2101295cafc5c3c54c6ae16edfff39 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Fri, 9 Aug 2024 19:19:04 -0400 Subject: [PATCH 1/4] docs: builds an initial example for Jenkins in docs Signed-off-by: Jennifer Power --- docs/tutorials/jenkins.md | 65 +++++++++++++++++++++++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 66 insertions(+) create mode 100644 docs/tutorials/jenkins.md diff --git a/docs/tutorials/jenkins.md b/docs/tutorials/jenkins.md new file mode 100644 index 00000000..a30a0355 --- /dev/null +++ b/docs/tutorials/jenkins.md @@ -0,0 +1,65 @@ +# Jenkins Tutorial + + +By specifying the git provider flags (i.e. `git-provider-type` and/or `git-server-url`) in `trestle-bot`, the application can be run in any CI tool can execute jobs in a container. Below we will explore how to use `trestle-bot` with [Jenkins](https://www.jenkins.io/). + +
+ Optionally set up a test environment + + **Prerequisites** + + This tutorial will include how to stand up a local Jenkins environment for testing. To get started, ensure you have the following prerequisites: installed: + + - [Podman](https://podman.io/docs/installation) + - [OpenShift Local](https://docs.redhat.com/en/documentation/red_hat_openshift_local/2.18/html/getting_started_guide/installation_gsg) + - [Podman Desktop](https://podman.io/docs/installation) + + + **High Level Steps** + + 1. Run `crc setup` to ensure you system is properly configured + 2. Obtain your [pull secret](https://console.redhat.com/openshift/create/local) + 3. Initialize and start OpenShift [local](https://podman-desktop.io/docs/openshift/openshift-local) + 4. Get `oc` in your path by running `eval $(crc oc-env)` + 5. Get cluster credentials through `crc console --credentials` and run the `oc login` command + 6. Create a new project - `oc new-project jenkins-test` + 7. Deploy Jenkins with the template - `oc new-app jenkins-ephemeral` + +
+ +### Build a basic [Jenkins Job Builder](https://docs.openstack.org/infra/jenkins-job-builder/) job template for trestle-bot + +1. Install `jenkins-job-builder`: `pip install --user jenkins-job-builder` +2. [Configure](https://jenkins-job-builder.readthedocs.io/en/latest/execution.html) `jenkins-job-builder` +3. Create and apply `jenkins-jobs update jobs/my-job.yml` + +```yaml +- job-template: + name: 'trestlebot-{git_repo}-autosync' + description: "DO NOT EDIT" + concurrent: false + properties: + - github: + url: https://github.com/{git_organization}/{git_repo}/ + scm: + - git-scm: + git_url: https://{github_user}@github.com/{git_organization}/{git_repo}.git + branches: + - main + triggers: + - github + builders: + - shell: | + trestlebot-autosync --markdown-path={markdown} --oscal-model={model} + +- project: + name: my-oscal-project + jobs: + - 'trestlebot-{git_repo}-autosync': + git_organization: my-org + git_repo: my-repo + markdown: md_profiles + model: profile +``` + + diff --git a/mkdocs.yml b/mkdocs.yml index f0ee2ad1..f9f84b1e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,6 +24,7 @@ theme: name: Switch to light mode markdown_extensions: + - md_in_html - toc: toc_depth: 2 - pymdownx.superfences: From 59a49c3afaea9fa21da5e3fdbe9d712b6ede1ffe Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Fri, 9 Aug 2024 20:27:41 -0400 Subject: [PATCH 2/4] docs: add Jenkins example with Groovy Signed-off-by: Jennifer Power --- docs/tutorials/jenkins.md | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/jenkins.md b/docs/tutorials/jenkins.md index a30a0355..1ad75c16 100644 --- a/docs/tutorials/jenkins.md +++ b/docs/tutorials/jenkins.md @@ -27,7 +27,7 @@ By specifying the git provider flags (i.e. `git-provider-type` and/or `git-serve -### Build a basic [Jenkins Job Builder](https://docs.openstack.org/infra/jenkins-job-builder/) job template for trestle-bot +## Build a basic [Jenkins Job Builder](https://docs.openstack.org/infra/jenkins-job-builder/) job template for trestle-bot 1. Install `jenkins-job-builder`: `pip install --user jenkins-job-builder` 2. [Configure](https://jenkins-job-builder.readthedocs.io/en/latest/execution.html) `jenkins-job-builder` @@ -62,4 +62,29 @@ By specifying the git provider flags (i.e. `git-provider-type` and/or `git-serve model: profile ``` +## Example with Groovy + +```groovy +pipeline { + agent { + docker { + image 'quay.io/continuouscompliance/trestle-bot:v0.10' + args "-v ${WORKSPACE}:/trestle-workspace -w /trestle-workspace --entrypoint=''" + reuseNode true + } + } + stages { + stage('Autosync') { + parameters { + string(name: 'MARKDOWN', defaultValue: 'md_profiles', description: 'Markdown path to use') + string(name: 'MODEL', defaultValue: 'profile', description: 'OSCAL model to author') + } + steps { + sh 'trestlebot-autosync --markdown-path=${params.MARKDOWN} --oscal-model=${params.MODEL} ' + } + } + } +} +``` + From e9b3b63fae18845d5035a714e3431fb580c5f420 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Sat, 10 Aug 2024 12:06:54 -0400 Subject: [PATCH 3/4] fix: updates jenkins.md with grammar fixes Signed-off-by: Jennifer Power --- docs/tutorials/jenkins.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/jenkins.md b/docs/tutorials/jenkins.md index 1ad75c16..1ce799cf 100644 --- a/docs/tutorials/jenkins.md +++ b/docs/tutorials/jenkins.md @@ -1,14 +1,14 @@ # Jenkins Tutorial -By specifying the git provider flags (i.e. `git-provider-type` and/or `git-server-url`) in `trestle-bot`, the application can be run in any CI tool can execute jobs in a container. Below we will explore how to use `trestle-bot` with [Jenkins](https://www.jenkins.io/). +By specifying the git provider flags (i.e. `git-provider-type` and/or `git-server-url`) in `trestle-bot`, the application can be run in any CI tool that can execute jobs in a container environment. Below we will explore how to use `trestle-bot` with [Jenkins](https://www.jenkins.io/).
Optionally set up a test environment **Prerequisites** - This tutorial will include how to stand up a local Jenkins environment for testing. To get started, ensure you have the following prerequisites: installed: + This tutorial will include how to stand up a local Jenkins environment for testing. To get started, ensure you have the following prerequisites installed: - [Podman](https://podman.io/docs/installation) - [OpenShift Local](https://docs.redhat.com/en/documentation/red_hat_openshift_local/2.18/html/getting_started_guide/installation_gsg) From 73090b3d34cb072efb0e95294c1d696a57e19651 Mon Sep 17 00:00:00 2001 From: Jennifer Power Date: Sat, 10 Aug 2024 12:16:24 -0400 Subject: [PATCH 4/4] fix: fixes typo in jenkins.md Signed-off-by: Jennifer Power --- docs/tutorials/jenkins.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/jenkins.md b/docs/tutorials/jenkins.md index 1ce799cf..ee7a5b62 100644 --- a/docs/tutorials/jenkins.md +++ b/docs/tutorials/jenkins.md @@ -17,7 +17,7 @@ By specifying the git provider flags (i.e. `git-provider-type` and/or `git-serve **High Level Steps** - 1. Run `crc setup` to ensure you system is properly configured + 1. Run `crc setup` to ensure your system is properly configured 2. Obtain your [pull secret](https://console.redhat.com/openshift/create/local) 3. Initialize and start OpenShift [local](https://podman-desktop.io/docs/openshift/openshift-local) 4. Get `oc` in your path by running `eval $(crc oc-env)`