Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@frekele
Created August 4, 2016 06:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save frekele/d1bc5ca04b1b1f2f78a60bbc2e7f6cf1 to your computer and use it in GitHub Desktop.
Save frekele/d1bc5ca04b1b1f2f78a60bbc2e7f6cf1 to your computer and use it in GitHub Desktop.
Jenkinsfile pipelineTriggers - TimerTrigger periodic run the aws-update-my-dynamic-ip.sh script.
#!groovy
MAIL_FROM = 'noreply-jenkins@myhost.io'
MAIL_TO = 'jenkins@myhost.io'
GITHUB_PROTOCOL = 'https'
GITHUB_USER_NAME = 'my-github-user'
GITHUB_USER_EMAIL = 'jenkins@myhost.io'
GITHUB_REPO = 'github.com/my-user/my-repository'
GITHUB_PROJECT_URL = "${GITHUB_PROTOCOL}://${GITHUB_REPO}"
node {
try {
properties(
[
[
$class : 'jenkins.model.BuildDiscarderProperty',
strategy: [
$class : 'LogRotator',
numToKeepStr: '200'
]
],
[
$class : 'GithubProjectProperty',
displayName : '',
projectUrlStr: "${GITHUB_PROJECT_URL}"
],
pipelineTriggers(
[
[
$class: 'hudson.triggers.TimerTrigger',
spec : "*/5 * * * *"
]
]
)
]
)
stage 'Clean Workspace'
deleteDir()
sh 'ls -lah'
sh 'env'
stage 'Checkout Source'
sh "git config --global user.name ${GITHUB_USER_NAME}"
sh "git config --global user.email ${GITHUB_USER_EMAIL}"
checkout scm
sh 'chmod +x *.sh'
stage 'Update dynamic-ip-myhosts'
sh './aws-update-my-dynamic-ip.sh dynamic-ip-myhosts'
}
catch (Exception ex) {
mail from: "${MAIL_FROM}",
to: "${MAIL_TO}",
subject: "[FAILURE] 💩 😵 [JENKINS] ${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - [FAILURE]! 👻 😭 ",
body: "${env.JOB_NAME} - Build # ${env.BUILD_NUMBER} - FAILURE (${ex.message})!"
throw ex
}
}
@frekele
Copy link
Author

frekele commented Aug 4, 2016

@evgeniikozhanov
Copy link

It's great!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment