Resources: https://github.com/ricardoandre97/jenkins-resources
- hosts: inventory is a file where we define all our hosts
- playbook: script that define all the thing ansible should do
- Install then Ansible plugins
- Install AnsiColor plugin
- Role based authorization strategy
- Always use the Role based strategy (look for Item Role)
-
Create custom ENV variables
- Go to configure system -> environment variables
-
Change Jenkins URL
-
Execute job automatically using CRON jobs
- configure job
- build triggers -> build periodically -> cron expression
-
Create a generic user to trigger jobs externally
- Install plugin Strict Crumb Issuer
- Manage jenkins -> configure global security -> CSRF Protection -> Prevent Cross Site Request Forgery exploits -> Strict Crumb Issuer -> 2h -> Prevent Breach
-
Trigger a job from bash script
- generate crumb :
crumb=$(curl -u "user:password" -s 'http://localhost:8081/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)')
- call job with crum:
curl -u "user:password" -H "$crumb" -X POST http://localhost:8081/job/demo-ENV/build?delay=0sec
- generate crumb :
-
Trigger a job from bash script with parameter
-
Install Mail plugin (Mailer Plugin)
-
AWS SES
- Email Addresses -> Create new email addresses
- SMTP Settings -> Create new SMTP credentials
- Use one of the SMTP Port
-
Jenkins -> Configure Global
- Email Notification -> Use SMTP Authentication.
- Jenkins Location -> System Admin email-address
- Test configuration
- Use SMPT Gmail server
- Activate less secure app
- Install Maven Plugin (may be built-in)
- Install GIT Plugin (may be built-in)
- Find simple Maven app (https://github.com/jenkins-docs/simple-java-maven-app)
- Global tool config -> add maven
- Configure the Job -> Build step -> Invoke top-level Maven Targets
- Configure Job
- Add post-build -> Publish JUnit test result report
- Add regex for
surefire-reports/*.xml
...something liketarget/surefire-reports/*.xml
- Configure Job
- Add post-build -> Archive the artifact
- Add regex for
target/*.jar
Doc : https://docs.gitlab.com/ee/install/docker.html#install-gitlab-using-docker-compose
- Create jobs from code
- Seed job : a job that create all jobs. Like the parent of all other jobs
Doc : https://jenkinsci.github.io/job-dsl-plugin/
Security : By default, Job DSL scripts are not enabled.
- Global security config -> uncheck enable Job DSL security
-
Install the Jenkins Pipeline plugin
-
Retry: retry command if fail
environment {
secret = credentials('SECRET_TEXT')
}
- Look at Dockerfile in pipeline
- Bind docker socket in docker-compose
Possible error of permission on docker.sock