├── .gitignore
├── README.md
├── resources
├── com
│ └── planetpope
│ │ ├── api
│ │ └── jira
│ │ │ ├── addComment.json
│ │ │ └── createIssue.json
│ │ ├── emailtemplate
│ │ └── build-results.html
│ │ ├── maven-settings
│ │ └── artifactory-settings.xml
│ │ └── scripts
│ │ ├── linux
│ │ └── hello-world.sh
│ │ └── windows
│ │ └── hello-world.bat
└── test.properties
├── src
└── AddSidebarLinkAction.groovy
└── vars
├── addSidebarLink.groovy
├── addSidebarLink.txt
├── closurePipeline.groovy
├── createArtifactoryMavenSettingsFile.groovy
├── deployApplication.groovy
├── deployContentProd.groovy
├── easyPipeline.groovy
├── evenOdd.groovy
├── fooProject.groovy
├── getCloudBeesFeatureManagementFlag.groovy
├── getEventValue.groovy
├── getIssueIdFromCommitMessage.groovy
├── getProjectFromJob.groovy
├── getProperty.groovy
├── getPropertyValueFromResources.groovy
├── getPullRequestInfo.groovy
├── getPullRequestInfoInternal.groovy
├── getPulumiStack.groovy
├── getRoxyContainerId.groovy
├── getRoxyListenerPort.groovy
├── getValueOrDefault.groovy
├── gitAuthorEmail.groovy
├── gitAuthorName.groovy
├── gitCheckout.groovy
├── heartQ.groovy
├── helloWorld.groovy
├── helloWorldExternal.groovy
├── helloWorldExternal.txt
├── helloWorldSimple.groovy
├── indigenous-cloudbees.groovy
├── indigenous.groovy
├── indigenousPod.groovy
├── javaMaven.groovy
├── javaMavenNexus.groovy
├── jiraAddComment.groovy
├── jiraCreateIssue.groovy
├── jiraProcessChangeLogItems.groovy
├── lazyDocker.groovy
├── loadLinuxScript.groovy
├── monoRepoPipeline.groovy
├── pipelineLoadYamlFile.groovy
├── prepareBuildEnvironment.groovy
├── publishArtifacts.groovy
├── renderTemplate.groovy
├── runCommand.groovy
├── sendEmail.groovy
├── sendIndigenousEmail.groovy
├── sendNotification.groovy
├── setCloudBeesFeatureManagementFlag.groovy
├── sonar.groovy
├── superEasyPipeline.groovy
└── wip.groovy
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | .idea
3 |
4 | # Mobile Tools for Java (J2ME)
5 | .mtj.tmp/
6 |
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 |
12 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
13 | hs_err_pid*
14 | .dccache
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # github-api-global-lib
--------------------------------------------------------------------------------
/resources/com/planetpope/api/jira/addComment.json:
--------------------------------------------------------------------------------
1 | {
2 | \"body\": \"$body\"
3 | }
4 |
--------------------------------------------------------------------------------
/resources/com/planetpope/api/jira/createIssue.json:
--------------------------------------------------------------------------------
1 | {
2 | \"fields\": {
3 | \"project\":
4 | {
5 | \"key\": \"$key\"
6 | },
7 | \"summary\": \"$summary\",
8 | \"description\": \"$description\",
9 | \"issuetype\": {
10 | \"name\": \"$issueTypeName\"
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/resources/com/planetpope/emailtemplate/build-results.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Jenkins Build Results - $applicationName
5 |
6 |
7 |
8 | - Build Job: $applicationName
9 | - Source Branch: $sourceBranch
10 | - Build Number: $buildNumber
11 | - Developer: $developer
12 | - Build URL: $buildUrl
13 |
14 |
15 |
--------------------------------------------------------------------------------
/resources/com/planetpope/maven-settings/artifactory-settings.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 | $artifactoryId
6 | $artifactoryMavenUser
7 | $artifactoryMavenPassword
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/resources/com/planetpope/scripts/linux/hello-world.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | echo Hello $1. Today is $2.
3 |
--------------------------------------------------------------------------------
/resources/com/planetpope/scripts/windows/hello-world.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | echo "Hello World!!!"
3 |
--------------------------------------------------------------------------------
/resources/test.properties:
--------------------------------------------------------------------------------
1 | foo=bar
--------------------------------------------------------------------------------
/src/AddSidebarLinkAction.groovy:
--------------------------------------------------------------------------------
1 | public class AddSidebarLinkAction implements hudson.model.Action,java.io.Serializable {
2 | private String displayName;
3 | private String iconFileName;
4 | private String urlName;
5 | private String iconClassName;
6 |
7 | public AddSidebarLinkAction(String displayName,String iconFileName,String urlName,String iconClassName) {
8 | this.displayName = displayName;
9 | this.iconFileName = iconFileName;
10 | this.urlName = urlName;
11 | this.iconClassName = iconClassName;
12 | }
13 |
14 | @Override
15 | public String getDisplayName() {
16 | return displayName;
17 | }
18 |
19 | @Override
20 | public String getIconFileName() {
21 | return iconFileName;
22 | }
23 |
24 | @Override
25 | public String getUrlName() {
26 | return urlName;
27 | }
28 |
29 | public String getIconClassName() {
30 | return iconClassName;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/vars/addSidebarLink.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | //def action = new hudson.plugins.sidebar_link.LinkAction("http://www.darinpope.com/","testLinkFromDarin","star.gif")
3 | def action = new hudson.plugins.sidebar_link.LinkAction(config.url,config.text,config.icon)
4 | currentBuild.rawBuild.addAction(action)
5 | }
--------------------------------------------------------------------------------
/vars/addSidebarLink.txt:
--------------------------------------------------------------------------------
1 | This is the help file for addSidebarLink
2 |
--------------------------------------------------------------------------------
/vars/closurePipeline.groovy:
--------------------------------------------------------------------------------
1 | def call(body) {
2 | def pipelineParams= [:]
3 | body.resolveStrategy = Closure.DELEGATE_FIRST
4 | body.delegate = pipelineParams
5 | body()
6 |
7 | pipeline {
8 | agent { label "master" }
9 | stages {
10 | stage("echo parameters") {
11 | steps {
12 | sh "env | sort"
13 | }
14 | }
15 | stage("Prepare Build Environment") {
16 | steps {
17 | echo 'prepare'
18 | }
19 | }
20 | stage("Source Code Checkout") {
21 | steps {
22 | echo 'scc'
23 | }
24 | }
25 | stage("SonarQube Scan") {
26 | when {
27 | equals expected: "toomuch", actual: pipelineParams?.sonar?.sing
28 | }
29 | steps {
30 | echo 'scan'
31 | }
32 | }
33 | stage("Build Application") {
34 | steps {
35 | echo 'build'
36 | }
37 | }
38 | stage("Publish Artifacts") {
39 | steps {
40 | echo 'publish'
41 | }
42 | }
43 | stage("Deploy Application") {
44 | steps {
45 | echo 'deploy'
46 | }
47 | }
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/vars/createArtifactoryMavenSettingsFile.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | def rawBody = libraryResource 'com/planetpope/maven-settings/artifactory-settings.xml'
3 | def binding = [
4 | artifactoryMavenUser : env.ARTIFACTORY_MAVEN_USR,
5 | artifactoryMavenPassword : env.ARTIFACTORY_MAVEN_PSW,
6 | artifactoryId : config.id
7 | ]
8 | def render = renderTemplate(rawBody,binding)
9 | writeFile(file:"artifactory-settings.xml", text: render)
10 | }
11 |
--------------------------------------------------------------------------------
/vars/deployApplication.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config) {
2 | echo 'inside deployApplication'
3 | echo "${config.name}"
4 | sh 'env > env.txt'
5 | for (String i : readFile('env.txt').split("\r?\n")) {
6 | echo i
7 | }
8 | echo gitAuthorName()
9 | echo gitAuthorEmail()
10 | }
--------------------------------------------------------------------------------
/vars/deployContentProd.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | def application
3 | def version
4 | def event = currentBuild?.getBuildCauses()[0]?.event?.event?.toString()
5 | def causeClass = currentBuild?.getBuildCauses()[0]?._class
6 | if(event == "deploy-content-prod" && causeClass == "com.cloudbees.jenkins.plugins.pipeline.events.EventTriggerCause") {
7 | application = currentBuild?.getBuildCauses()[0]?.event?.application?.toString()
8 | version = currentBuild?.getBuildCauses()[0]?.event?.version?.toString()
9 | } else {
10 | application = params.application
11 | version = params.version
12 | }
13 | sh """
14 | echo version = $version
15 | echo application = $application
16 | """
17 | }
18 |
--------------------------------------------------------------------------------
/vars/easyPipeline.groovy:
--------------------------------------------------------------------------------
1 | def call(String agentLabel,body) {
2 |
3 | def pipelineParams= [:]
4 | body.resolveStrategy = Closure.DELEGATE_FIRST
5 | body.delegate = pipelineParams
6 | body()
7 |
8 | pipeline {
9 | agent none
10 | stages {
11 | stage("echo parameters") {
12 | agent { label "${agentLabel}" }
13 | steps {
14 | sh "env | sort"
15 | echo "${agentLabel}"
16 | echo "${pipelineParams.osConfiguration}"
17 | echo "${pipelineParams.osConfiguration.OS_VERSION}"
18 | echo "${pipelineParams.osConfiguration.DIR_TYPE}"
19 | }
20 | }
21 | stage("Prepare Build Environment") {
22 | agent { label "${agentLabel}" }
23 | steps {
24 | prepareBuildEnvironment()
25 | helloWorld(name: "prepareBuildEnvironment")
26 | helloWorldExternal()
27 | }
28 | }
29 | stage("Source Code Checkout") {
30 | agent { label "${agentLabel}" }
31 | steps {
32 | echo 'scc'
33 | }
34 | }
35 | stage("SonarQube Scan") {
36 | agent { label "${agentLabel}" }
37 | when {
38 | branch 'master'
39 | }
40 | steps {
41 | echo 'scan'
42 | }
43 | }
44 | stage("Build Application") {
45 | agent { label "${agentLabel}" }
46 | steps {
47 | echo 'build'
48 | }
49 | }
50 | stage("Publish Artifacts") {
51 | agent { label "${agentLabel}" }
52 | steps {
53 | publishArtifacts(name: "publishArtifacts")
54 | }
55 | }
56 | stage("Deploy Application") {
57 | agent { label "${agentLabel}" }
58 | steps {
59 | deployApplication(name: "deployApplication")
60 | }
61 | }
62 | //stage("Long Running Stage") {
63 | // agent { label "${agentLabel}" }
64 | // steps {
65 | // script {
66 | // hook = registerWebhook()
67 | // }
68 | // }
69 | //}
70 | //stage("Waiting for Webhook") {
71 | // steps {
72 | // echo "Waiting for POST to ${hook.getURL()}"
73 | // script {
74 | // data = waitForWebhook hook
75 | // }
76 | // echo "Webhook called with data: ${data}"
77 | // }
78 | //}
79 | }
80 | //post {
81 | // always {
82 | // sendNotification()
83 | // }
84 | //}
85 | post {
86 | always {
87 | addSidebarLink()
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/vars/evenOdd.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config) {
2 | if(env.BUILD_NUMBER.toInteger() % 2 == 0) {
3 | return true
4 | }
5 | return false
6 | }
--------------------------------------------------------------------------------
/vars/fooProject.groovy:
--------------------------------------------------------------------------------
1 | def call(body) {
2 | def pipelineParams = [:]
3 | body.resolveStrategy = Closure.DELEGATE_FIRST
4 | body.delegate = pipelineParams
5 | body()
6 |
7 | println(pipelineParams)
8 | }
9 |
--------------------------------------------------------------------------------
/vars/getCloudBeesFeatureManagementFlag.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | def curl = 'curl -H "Content-Type: application/json" -H "Authorization: Bearer ' + env.CBFM_USER_TOKEN + '" https://x-api.rollout.io/public-api/applications/'+config.applicationId+'/'+config.environment+'/flags/'+config.flagName+"| jq 'if .enabled == true then .value else empty end'"
3 |
4 | def flagValue = sh(returnStdout:true,script:curl).trim()
5 | return flagValue;
6 | }
--------------------------------------------------------------------------------
/vars/getEventValue.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | return currentBuild.getBuildCauses()[0]["event"]["${config.key}"].toString()
3 | }
--------------------------------------------------------------------------------
/vars/getIssueIdFromCommitMessage.groovy:
--------------------------------------------------------------------------------
1 | def call(Map config=[:]) {
2 | def rawIssueId = sh(returnStdout: true,script: "git log --oneline --format=%B -n 1 $GIT_COMMIT | head -n 1 | cut -d' ' -f1")
3 | //echo "rawIssueId = ${rawIssueId}"
4 | def issueId = rawIssueId.replaceAll("[^a-zA-Z0-9-]+","")
5 | if( issueId ==~ /((?