diff --git a/README.md b/README.md new file mode 100644 index 0000000..76e082a --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Tools4Jenkins Generated Lib - Sample + +This library is part of Tools4Jenkins environnment. It should not be edited in other ways than `wks generate-lib` command in Tools4Jenkins repository. +More over this library is the result of *configT4JSample* and *Tools4Jenkins* repository in order to build Jenkins library repository from a generic base and project specific customization diff --git a/src/project/cmake/Sequential.groovy b/src/project/cmake/Sequential.groovy new file mode 100644 index 0000000..ae66e09 --- /dev/null +++ b/src/project/cmake/Sequential.groovy @@ -0,0 +1,119 @@ +package project.cmake; + +def main(_Targets,_Stage){ + def M_T4d = new system.tools4dev() + def M_System = new system.workspace() + + switch(_Stage){ + case "Configure" : + stage("SCM"){ + try { + withCredentials([usernamePassword(credentialsId: 'jenkins_git_credentials', passwordVariable: 'userPassword', usernameVariable: 'userName')]) { + M_System.wksClean() + M_System.wksClone("http ${env.userName}:${env.userPassword} -force --single-branch","false") + } + } catch (err) { + M_System.wksClean() + error "Clone failed" + } + } + + + break + case "End" : + stage("End"){ + M_System.wksClean() + } + break + default : + lock("${env.M_Project}_${env.SlaveName}"){ + withCredentials([usernamePassword(credentialsId: "slave_default_user", passwordVariable: 'userPassword', usernameVariable: 'userName')]){ + M_T4d.exec("wks ${_Stage}") + } + } + break + } + + +} + +def notifBuildStarted(){ + def M_Irc= new webServices.irc() + M_Message="""{ + "attachments": [ + { + "color": "#313131", + "author_name": "${env.M_JobName} - ${env.M_Version}", + "author_link": "Author Link test", + "author_icon": "https://avatars1.githubusercontent.com/u/16338861?v=3&s=400", + "title": "Build #${env.BUILD_NUMBER} Started", + "title_link": "${env.M_CurrentBuildUrl}", + "fields": [ + { + "title": "Branch", + "value": "${env.BRANCH_NAME}", + "short": true + }, + { + "title": "Changes", + "value": "${env.M_GitSHA7} ${env.M_GitCommiterEmail}", + "short": true + } + ], + "thumb_url": "https://i.imgur.com/DBveMrC.png", + "footer": "Provided By iFeelSmart" + } + ] + }""" + M_Irc.SendMessage("${M_Message}","${env.M_IrcChannel}") +} + +def notifBuildFailed(_error='unkown'){ + def M_Irc= new webServices.irc() + M_Message="""{ + "attachments": [ + { + "color": "#313131", + "author_name": "${env.M_JobName} - ${env.M_Version}", + "author_link": "Author Link test", + "author_icon": "https://avatars1.githubusercontent.com/u/16338861?v=3&s=400", + "title": "Build #${env.BUILD_NUMBER} Failed", + "title_link": "${env.M_CurrentBuildUrl}", + "text": "${_error}", + "fields": [ + { + "title": "Branch", + "value": "${env.BRANCH_NAME}", + "short": true + }, + { + "title": "Changes", + "value": " ${env.M_GitCommiterEmail}", + "short": true + } + ], + "thumb_url": "https://i.imgur.com/d5QJtHJ.png", + "footer": "Provided By iFeelSmart" + } + ] + }""" + M_Irc.SendMessage("${M_Message}","${env.M_IrcChannel}") +} + +def notifBuildSucceeded(){ + def M_Irc= new webServices.irc() + M_Message="""{ + "attachments": [ + { + "color": "#313131", + "author_name": "${env.M_JobName} - ", + "author_link": "Author Link test", + "author_icon": "https://avatars1.githubusercontent.com/u/16338861?v=3&s=400", + "title": "Build #${env.BUILD_NUMBER} On branch ${env.BRANCH_NAME} Succeeded", + "title_link": "${env.M_CurrentBuildUrl}", + "thumb_url": "https://i.imgur.com/ZOvE5Mp.png" + } + ] + }""" + M_Irc.SendMessage("${M_Message}","${env.M_IrcChannel}") +} diff --git a/src/system/jenkins/configuration.groovy b/src/system/jenkins/configuration.groovy index 3bc5144..487193d 100644 --- a/src/system/jenkins/configuration.groovy +++ b/src/system/jenkins/configuration.groovy @@ -3,6 +3,7 @@ package system.jenkins; def getSlaveObject(_Uuid,_Scheme=''){ // echo "${env.M_CiPipeline} - ${env.JENKINS_URL} - ${_Scheme}" switch(_Uuid){ + case "CMake" : def m_Res=new slaves.main(); return m_Res; break default : m_Res="Unknown" error "getSlaveObject -> Unknown Project ${_Uuid}" @@ -14,6 +15,7 @@ def getSlaveObject(_Uuid,_Scheme=''){ def getSchemeObject(_Project){ switch(_Project){ + case "CMake" : def m_Res=new project.cmake.Sequential(); return m_Res; break default : m_Res="Unknown" error "getSchemeObject -> Unknown scheme ${_Project}"