Skip to content

Instantly share code, notes, and snippets.

@rafaftahsin
Last active May 24, 2023 13:31
Show Gist options
  • Save rafaftahsin/856649c09f3975ae64e1720c23836ed0 to your computer and use it in GitHub Desktop.
Save rafaftahsin/856649c09f3975ae64e1720c23836ed0 to your computer and use it in GitHub Desktop.
stage('Stage Name') {
steps {
build(job: 'pipeline.name', parameters: [string(name: 'DEPLOY_TO', value: "test")])
}
}
stage('Stage Name') {
steps {
build(job: 'Another Pipeline')
}
}
// Need to update the Themplate according to this documetation : https://jenkins.io/doc/book/pipeline/syntax/
pipeline {
agent any
environment {
CC = 'clang'
}
stages {
stage('Build') {
steps {
//
}
}
stage('Test') {
steps {
//
}
}
stage('Deploy') {
steps {
//
}
}
}
}
pipeline{
agent {
label 'build.machine'
}
environment {
GIT_URL = 'git@github.com:rafaftahsin/Unity-Jenkinsfile-Exmaple.git'
}
stages{
stage('Try Catch Block'){
steps {
script {
try {
sh '''
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -runEditorTests "$(pwd)" -testFilter "$(pwd)/Library/ScriptAssemblies/Assembly-CSharp.dll" -editorTestsResultFile "$(pwd)/unit_test_result.xml"
'''
}
catch (exc) {
sh 'cat unit_test_result.xml'
error("Build Failed Due to Test Fail.")
}
}
}
}
}
}
pipeline{
agent {
label 'build.machine'
}
environment {
GIT_URL = 'git@github.com:rafaftahsin/Unity-Jenkinsfile-Exmaple.git'
}
stages{
stage('Git Clone'){
steps {
deleteDir()
slackSend channel: '#hal-alerts', message: "${env.JOB_NAME} is started"
git branch: 'development', credentialsId: 'Jenkins Master SSH', url: "${GIT_URL}"
}
}
}
post {
always {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME}"
}
}
changed {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME} is CHANGED. See ${env.BUILD_URL} console for details."
}
}
failure {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME} is FAILED. See ${env.BUILD_URL} console for details."
}
}
success {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME} is SUCCESS. See ${env.BUILD_URL} console for details."
}
}
unstable {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME} is UNSTABLE. See ${env.BUILD_URL} console for details."
}
}
aborted {
script{
slackSend channel: '#channel-name', message: "${env.JOB_NAME} is ABORTED. See ${env.BUILD_URL} console for details."
}
}
}
}
node ('nodename'){
stage('Build') {
//
}
stage('Test') {
//
}
stage('Deploy') {
//
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment