Set up a Jenkins CI pipeline
Step 1 -Log onto Jenkins
- Visit http://your-linux-server:8080
- Log in with the username admin and the password that we use for the Windows VMs.
Step 2 - configure the database password in Jenkins
We don't want to store passwords in our files so we'll safely store this in Jenkins
- Click on the "manage Jenkins" cog icon at the top right of the screen
- In the "Security" section click on "Configure credentials"
- Click on "(global)" in the domains column
- Click on the "+ Add Credentials" button
- Set the Kind to "Secret text"
- Set the Scope to "Global"
- Set the Secret to the password for your database
- Set the id to "DBPASSWORD"
- Click on the "Create" button
Step 3 - create a pipeline
- Click on the Jenkins icon at the top left to get to the home page.
- Click on "Create a job"
- Give the job the name "bam-building" and choose "Pipeline" as the item type, then click on OK
- Scroll down to the Pipeline section and change the Definition to "Pipeline script from SCM"
- Set the SCM to "Git"
- Set the repository URL to "https://github.com/vppmatt/microservices-bam"
- Scroll down to the Branches to build section and set this to "main"
- Scroll down to the Script Path and set this to "07 - jenkins files/bam-building-jenkinsfile"
- Leave all other settings at the default and click on Save
Step 4 - run the pipeline
- Click on the Build now button on the left menu
Then to watch the logs:
- Click on the timestamp for the build id in the builds window below the left menu
- Click on console output from the left menu
Step 5 - deploy the change
NOTE - before starting this section you may wish to run watch microk8s kubectl get po to see the new container being deployed
get the tag number for the latest image for bam building
docker image ls
implement the changed image:
microk8s kubectl set image deployment/bam-building bam-building=bam-building:3