Skip to content

Commit

Permalink
jenkins-core-image ready DEVOPS-253
Browse files Browse the repository at this point in the history
  • Loading branch information
githubofkrishnadhas committed Jul 6, 2024
1 parent cbb6755 commit c659e2e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build-publish-jenkins-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
- name: Write to workflow job summary
run: |
SUMMARY=$'# Building jenkins-core-image\n'
SUMMARY=$'[jenkins-core-image available here](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-image)'
SUMMARY+=$'**Job Start 📅Time:** ${{ env.JOB_START_TIME }}\n'
SUMMARY+=$'**Job End📅 Time:** ${{ env.JOB_END_TIME }}\n'
SUMMARY=$'[jenkins-core-image available here](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-image)\n'
SUMMARY+=$'**Job Start 📅 Time:** ${{ env.JOB_START_TIME }}\n'
SUMMARY+=$'**Job End 📅 Time:** ${{ env.JOB_END_TIME }}\n'
echo "$SUMMARY" >> $GITHUB_STEP_SUMMARY
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ Create jenkins docker images and build them periodicaly and scan using trivy

* user.groovy --> This creates a user with name as of `JENKINS_USER` and with password `JENKINS_PASS` who will be the default user and security will be enabled using `Jenkins OWN Databse` by default.

* number_of_executors.groovy --> this script is used to increase the `numOfExecutors` in Jenkins from 2 to `x` where `x` is the value of numberOfExecutors provided in the script.

* get_latest_version_create_tag.sh --> gets the tag to create on github and set it as a github env variable and push tag to github

* config-as-code.yaml --> This uses Configuration as Code plugin from Jenkins to set up some default settings like setting up a GitHub App as a credential, default executors count etc.
* config-as-code.yaml --> This uses Configuration as Code plugin from Jenkins to set up some default settings like setting up a GitHub App as a credential.

* **To use JCasC, you need to install the Configuration as Code plugin.** [configuration-as-code](https://plugins.jenkins.io/configuration-as-code/)

Expand Down Expand Up @@ -50,12 +52,14 @@ Eg: docker build --build-arg JENKINS_USER=user --build-arg JENKINS_PASS=passwor
Details can be found here - [github-app-auth](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/github-app-auth)

* Post generating the Private key of GitHub app, this needs to be converted into a specific format
Use the command [here](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/github-app-auth#_converting_the_private_key_for_jenkins)
Use the command [here](https://docs.cloudbees.com/docs/cloudbees-ci/latest/cloud-admin-guide/github-app-auth#_converting_the_private_key_for_jenkins) , This will be the value we will be passing as `GITHUB_APP_KEY`

```
openssl pkcs8 -topk8 -inform PEM -outform PEM -in <key-in-your-downloads-folder.pem> -out <converted-github-app.pem> -nocrypt
```
* <key-in-your-downloads-folder.pem> --> Replace with your pem file path of app private key.
* <converted-github-app.pem> --> The converted output which you need to update to jenkins.

I am passing the `GITHUB_APP_KEY` & `GITHUB_APP_ID` at build time from github secrets and storing it as env variables in image.
I am passing the `GITHUB_APP_KEY` & `GITHUB_APP_ID` at build time from github secrets and storing it as env variables in image.

# Image 👉 [jenkins-core-image available here](https://hub.docker.com/r/dockerofkrishnadhas/jenkins-core-image)
7 changes: 4 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ services:
environment:
- JENKINS_ADMIN
- JENKINS_ADMIN_PASSWORD
- GITHUB_APP_KEY=${{ secrets.GH_APP_KEY }}
- GITHUB_APP_ID=${{ secrets.GH_APP_ID }}
- GITHUB_APP_KEY
- GITHUB_APP_ID
# - JAVA_OPTS="-Djenkins.install.runSetupWizard=false" this is already passed as an env variable in build time and will be present
volumes:
- jenkins-data:/var/jenkins_home
Expand All @@ -23,4 +23,5 @@ volumes:
jenkins-data:
driver: local
networks:
jenkins:
jenkins:
# Using this by providing all necessary variables, we can build and deploy jenkins straight away.

0 comments on commit c659e2e

Please sign in to comment.