This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Updates Jira Fixed in build field with the build number and adds a comment in each related Jira issue | |
* This requires the Jenkins JIRA Pipeline Steps plugin https://jenkinsci.github.io/jira-steps-plugin/getting-started/ | |
* @param build Build number that will be entered in the "Fixed in Build" Jira field | |
*/ | |
def updateJira(build) { | |
def jiraServer = 'JIRA-PROD' // Define a Jira server entry in the Jenkins Jira Steps configuration named JIRA-PROD | |
def jiraIssues = jiraIssueSelector(issueSelector: [$class: 'DefaultIssueSelector']) | |
jiraIssues.each { issue -> | |
jiraAddComment comment: "{panel:bgColor=#97FF94}{code}Code was added to address this issue in build ${build}{code} {panel}", idOrKey: issue, site: jiraServer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getJiraIssueList() { | |
/** | |
* Returns an HTML formatted list of Jira issues related in the build. | |
* This requires the Jenkins JIRA Pipeline Steps plugin https://jenkinsci.github.io/jira-steps-plugin/getting-started/ | |
* @param None | |
* @return An HTML string containing Jira issues | |
*/ | |
def jiraServer = 'JIRA-PROD' // Define a Jira server entry in the Jenkins Jira Steps configuration named JIRA-PROD | |
def jiraURL = "http://my.jiraserver.com:8080" // Define the Jira URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def deployToCIFS(prefix = "", cifsConfig, destination) { | |
/** | |
* Copies file artifacts to a given CIFS share and folder. | |
* This requires the Jenkins Publish over CIFS plugin https://wiki.jenkins.io/display/JENKINS/Publish+Over+CIFS+Plugin | |
* @param prefix The file artifact's folder prefix. Everything after this prefix will be copied to the destination. The destination will not include this folder structure. Note that this is case-sensitive. | |
* @cifsConfig The CIFS configuration defined in the Jenkins Publish over CIFS system configuration. | |
* @destination The folder appended to the CIFS share to create a fully qualified path of the destination. | |
*/ | |
cifsConfig = 'myShare' // Define a share named "myShare" in the Jenkins Publish over CIFS system configuration | |
srcFiles = "${prefix}/**/**" // Copy everything after prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prints environment variables and their values in the console | |
*/ | |
def printParams() { | |
bat 'set > env.txt' | |
for (String i : readFile('env.txt').split("\r?\n")) { | |
println i | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are instructions on how to get DOS directory output into Microsoft Excel. | |
1. Pipe directory output to a file, dir /A-D > files.txt | |
2. Open the file into Notepad and copy the rows containing the file listing. | |
3. Open Microsoft Excel. | |
4. Open the Home menu and click on the Paste down arrow to show past options. | |
5. Select "Use Text Import Wizard." | |
From this point on, use the Text Import Wizard to import the text into Microsoft Excel. Defaults should be sufficient. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def jenkinsBase = // Set to Jenkins base URL | |
def jenkinsJob = // Set to Jenkins job name | |
def address = null | |
def response = null | |
def start = 0 // Start at offset 0 | |
def cont = true // This semaphore holds the value of X-More-Data header value | |
try { | |
while (cont == true) { // Loop while X-More-Data value is equal to true | |
address = "${jenkinsBase}/job/${jenkinsJob}/lastBuild/logText/progressiveText?start=${start}" | |
println("${address}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib | |
import urllib2 | |
import time | |
import sys | |
JENKINS_BASE = # Set to Jenkins base URL | |
JENKINS_JOB = # Set to Jenkins job | |
start = 0 # | |
job_number='lastBuild' # Get the last build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def address = "http://{jenkinsBase}/job/${jobName}/lastBuild/buildNumber" | |
try { | |
println("${address}") | |
def urlInfo = address.toURL() | |
response = urlInfo.openConnection() | |
if (response.getResponseCode() != 200) { | |
throw new Exception("Unable to connect to " + address) // Throw an exception to get out of loop if response is anything but 200 | |
} | |
buildNum= response.getInputStream().getText() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set objWSHShell = CreateObject("WScript.Shell") | |
'=========================================== | |
' usage: cscript makeLNK.vbs shortcut target | |
'============================================ | |
sShortcut = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(0)) | |
sTargetPath = objWSHShell.ExpandEnvironmentStrings(WScript.Arguments.Item(1)) | |
set objSC = objWSHShell.CreateShortcut(sShortcut) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following snippet shows how to get the Jenkins Application URL | |
// from the Jenkins configuration settings. | |
// The following must be approved in the Jenkins In-process Script Approval | |
// | |
// staticMethod jenkins.model.JenkinsLocationConfiguration get | |
// method jenkins.model.JenkinsLocationConfiguration getUrl | |
jlc=JenkinsLocationConfiguration.get() | |
echo jlc.getUrl() |
OlderNewer