Skip to content

Commit

Permalink
adding pipeline scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
yankils committed May 25, 2020
1 parent 4619955 commit 4429011
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 0 deletions.
39 changes: 39 additions & 0 deletions jenkins/Enable_email_notification_on_Jenkins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Enable email notification on Jenkins

## pre-requisites
1. A Jenkins Server [Click here to create]()

## Integration Steps
Log into the Jenkins to install mailer plugin

1. Install "mailer" plug-in
- `Manage Jenkins` -> `Manage Plugins` -> `available` -> `mailer`

2. Configure Mailer
- `Manage Jenkins` -> `Configure System`
- E-mail Notification:
- SMTP server : `smtp.gmail.com`
- Advanced:
- [x] `Use SMTP Authentication`
- User Name : `valaxytech@gmail.com`
- Passwrod : `<password>`
- [x] `Use SSL`
- SMTP Port: `465`
- Charset : `UTF-8 (Auto filled)`
#### Unable to authonticate?
please allow your gmail to access "less security apps" [click here to enable](https://myaccount.google.com/intro/security)
---
---
### Create a Freestyle Project

1. Create a new job
- Job Name : `test-email-job`
- Source code management
- Git URL : [get URL here](https://github.com/yankils/hello-world.git)
- Build Environment
- Maven3-Artifactory Integration : `<provide Artifactory server and repository details
>`
- Build --> Invoke Artifactory Maven3
- Goals: ` clean install`

# Still working
32 changes: 32 additions & 0 deletions jenkins/Run_a_Jenkins_job_with_GitHub_webhook
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Run a Jenkins job with GitHub webhook

## pre-requisites
1. A Jenkins Server [Click here for help]()
1. A GitHub repository [Click here for help]()

## Integration Steps
Log into the Jenkins

---
### Create a Freestyle Project

1. Create a new job
- Job Name : `WebhookTestJob`
- Source code management
- Git URL : [get URL here](https://github.com/yankils/hello-world.git)
- Build Triggers
- [X] `GitHub hook trigger for GITScm polling`

- Build --> `Add Build Step` --> `Invoke Top Level Maven Triggers`
- Maven Version: `Maven`
- Goals: ` clean install`

2. On GitHub repository

`repository` --> `settings` --> `webhooks`
- Add webhook
- Payload URL : `Jenkins_IP>:8080/github-webhook`
- Content type : `Application/JSON`

3. Update the code with new commit. It should trigger our job in the jenkins

21 changes: 21 additions & 0 deletions jenkins/pipeline-templates/01first-pipeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
pipeline {
agent any

stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
14 changes: 14 additions & 0 deletions jenkins/pipeline-templates/02multiple-steps
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo "My first pipeline"'
sh '''
echo "By the way, I can do more stuff in here"
ls -lah
'''
}
}
}
}
12 changes: 12 additions & 0 deletions jenkins/pipeline-templates/03retry
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
pipeline {
agent any
stages {
stage('Timeout') {
steps {
retry(3) {
sh 'I am not going to work :c'
}
}
}
}
}
16 changes: 16 additions & 0 deletions jenkins/pipeline-templates/04timeout
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipeline {
agent any
stages {
stage('Deploy') {
steps {
retry(3) {
sh 'echo hello'
}

timeout(time: 3, unit: 'SECONDS') {
sh 'sleep 5'
}
}
}
}
}
16 changes: 16 additions & 0 deletions jenkins/pipeline-templates/05env
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pipeline {
agent any

environment {
NAME = 'AR'
LASTNAME = 'Shankar'
}

stages {
stage('Build') {
steps {
sh 'echo $NAME $LASTNAME'
}
}
}
}
14 changes: 14 additions & 0 deletions jenkins/pipeline-templates/06creds
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pipeline {
agent any

environment {
secret = credentials('TEST')
}
stages {
stage('Example stage 1') {
steps {
sh 'echo $secret'
}
}
}
}
24 changes: 24 additions & 0 deletions jenkins/pipeline-templates/07post-actions
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'echo "Fail!"; exit 1'
}
}
}
post {
always {
echo 'I will always get executed :D'
}
success {
echo 'I will only get executed if this success'
}
failure {
echo 'I will only get executed if this fails'
}
unstable {
echo 'I will only get executed if this is unstable'
}
}
}
32 changes: 32 additions & 0 deletions jenkins/pipeline-templates/maven-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pipeline {
agent any

stages {
stage ('Compile Stage') {

steps {
withMaven(maven : 'maven') {
sh 'mvn clean compile'
}
}
}

stage ('Testing Stage') {

steps {
withMaven(maven : 'maven') {
sh 'mvn test'
}
}
}


stage ('Deployment Stage') {
steps {
withMaven(maven : 'maven') {
sh 'mvn deploy'
}
}
}
}
}

0 comments on commit 4429011

Please sign in to comment.