Last active
March 16, 2020 15:01
-
-
Save bmpc/272fb4fe98d1c3fc7f7839f70e4ee11a to your computer and use it in GitHub Desktop.
[Xray Server] Robot Framework Jenkins pipeline
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
pipeline { | |
environment { | |
xray_server = "https://xxxxx.com" | |
user = "********" | |
pwd = "********" | |
} | |
agent { | |
docker { | |
image 'robotframework/rfdocker' | |
args '--entrypoint=\'\'' | |
} | |
} | |
stages { | |
stage('SCM Clone'){ | |
steps { | |
git url: "https://github.com/robotframework/RobotDemo.git" | |
} | |
} | |
stage("Run Tests") { | |
steps { | |
script { | |
sh(script:"sudo apk --no-cache add curl") | |
sh(script:"pip install docutils") | |
echo "Executing Robot Tests..." | |
sh(script:"robot keyword_driven.robot", returnStatus:false) | |
def date = sh(returnStdout: true, script: "date").trim() | |
echo "Creating info file for Test Exec..." | |
def meta = readJSON text: "{ \ | |
\"fields\": { \ | |
\"project\": { \ | |
\"key\": \"BOOK\" \ | |
}, \ | |
\"issuetype\": { \ | |
\"name\": \"Test Execution\" \ | |
}, \ | |
\"summary\": \"Robot test results ${date}\", \ | |
\"fixVersions\": [ \ | |
{ \ | |
\"name\": \"1.0\" \ | |
} \ | |
] \ | |
} \ | |
}" | |
writeJSON file: "info.json", json: meta | |
echo "Creating info file for Test..." | |
def testMeta = readJSON text: "{ \ | |
\"fields\": { \ | |
\"labels\": [ \ | |
\"Testing\", \ | |
\"Automation\" \ | |
], \ | |
\"fixVersions\": [ \ | |
{ \ | |
\"name\": \"1.0\" \ | |
} \ | |
] \ | |
} \ | |
}" | |
writeJSON file: "testInfo.json", json: testMeta | |
echo "Uploading results to Xray..." | |
sh "curl \"Content-Type: multipart/form-data\" -X POST -k -u ${user}:${pwd} -F info=@info.json -F testInfo=@testInfo.json -F file=@output.xml ${xray_server}/rest/raven/1.0/import/execution/robot/multipart" | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment