This file contains hidden or 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
// This does not work if Use Groovy Sandbox is enabled | |
// Execute this as a system Groovy script in Jenkins | |
def thr = Thread.currentThread() | |
def build = thr?.executable | |
def env = build.parent.builds[0].properties.get("envVars") | |
env.each{ | |
println it | |
} |
This file contains hidden or 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
// Post to stop a running Jenkins job | |
build = 63 | |
jobName = // Set job name here | |
jlc=JenkinsLocationConfiguration.get() // Get Jenkins base URL from configuration | |
jenkinsBase = jlc.getUrl() | |
addr = "${jenkinsBase}job/${jobName}/${build}/stop" // Stop URL | |
authString = "frefol:d0882d0d535f52cc87f3ac3694d7ad61".getBytes().encodeBase64().toString() // Use authentication token | |
println("${addr}") | |
try { |
This file contains hidden or 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() |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |