Wildcard for directory name in Jenkinsfile using publishHTML not recognized - windows

In my Jenkinsfile I use publishHTML to publish report for PIT. My step is as follows
stage('Results') {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false,
keepAll: false, reportDir: 'target/pit-reports/*/', reportFiles: 'index.html', reportName: 'PIT Report'])
}
The directory of the index.html is something like this \target\pit-reports\201612081633. That last part 201612081633 is of course different every time. Using target/pit-reports/*/ on a windows machine results in the following error.
ERROR: Specified HTML directory 'D:\David\Tools\Jenkins\workspace\jenkinsSandbox\target\pit-reports\*' does not exist.
The wildcard * or ** does not work. How can I use a wildcard for a directory name in the jenkinsfile and is there any difference when doing this on windows or unix?

I solved this using a workaround because the publishHTML plugin seems to be unable to handle * or **. I now run pitest with -DtimestampedReports=false org.pitest:pitest-maven:mutationCoverage, which disables the timestamped folders. The result step now looks like this.
stage('Results') {
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'target/pit-reports',
reportFiles: 'index.html',
reportName: 'PIT Report'
])
}
For those who are interested, the full version of my Jenkinsfile can be found on my github repo.

Related

Exclude directory relative to project root

I work in a project that has two copies of the framework it uses, one of them not being used (please don't ask):
C:\Projects\Foo\app\Vendor\cakephp\cakephp
C:\Projects\Foo\lib\Cake
What's the syntax to completely obliterate \lib\Cake in files.exclude or search pane?
None of these seem to work:
/lib/Cake
/lib/Cake/
/lib/Cake/**
lib/Cake
lib/Cake/
lib/Cake/**
**/lib/Cake
**/lib/Cake/
**/lib/Cake/**
… plus the same patters with Windows style path separators.
They either ignore both copies or ignore none.
sample file
"files.exclude": {
"*/**/node_modules/": true,
"wp-includes/": true,
"wp-admin/": true,
//"wp-*.*": true,
"wp-config.*": false,
"xmlrpc.php": true,
".vscode/": true,
"*/**/cache/": true,
"*/**/uploads/": true,
"*/**/infinitewp/": true,
"*/**/.github/": true,
//"*/**/build/": true
},
"search.exclude": {
"build/": true,
},
taken from : https://daveredfern.com/hide-or-exclude-folders-and-files-from-search-in-visual-studio-code/

Compile/Build Issue with Img Relative Paths

I am building a site using Visual Studio and WebCompiler is enabled.
When I compile on build my path files are changing to:
../../img/icons-#2x.png
rather than what the expected outcome is:
../img/icons-#2x.png
This is my current compilerconfig.json file:
[
{
"outputFile": "dist/css/style.css",
"inputFile": "styles/style.scss",
"sourceMap": false,
"relativeUrls": false
}
]
I've racked my brains/googled for hours but cannot figure out what is causing this to happen?
Just to note I resolved this issue by including the following in my compilerconfig.json:
"options": {
"sourceMap": false,
"relativeUrls": false
}

Jenkins: Run Serenity acceptance tests without failure

I'm trying to achieve the following:
Run a set of Serenity (plus Cucumber) tests as part of a build pipeline
Collect the reports regardless of whether all tests passed or not (they are especially useful in failures obviously)
In the case of test failures only, then email the contributors
Never fail the build because of a failed acceptance test as this pipeline is for the commit CI. Only want to fail if there are broken acceptance tests in the Nightly.
So with all that in mind I set off attempting to configure the build:
stage ('Serenity') {
steps {
// For the Delivery CI build don't fail on regression failure
sh 'mvn clean verify -pl regression -DskipCuke=false'
}
post {
always {
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true,
keepAll: true, reportDir: 'regression/target/site/serenity',
reportFiles: 'index.html', reportName: 'Serenity',
reportTitles: ''])
}
failure{
echo 'There are regression suite failures.'
script {
currentBuild.result = 'SUCCESS'
}
emailext attachLog: true, body: 'Find Attached',
compressLog: true, recipientProviders: [[$class:
'CulpritsRecipientProvider']], subject: 'Broken Regression Tests',
to: 'dennis#dennis.ru'
}
}
}
However it does not work as I cannot reset the value of currentBuild.result to 'SUCCESS'. So I could all || true to the mvncommand, but that would mean that I can't email about the broken regression tests.
So I am wondering if anyone else out their has dealt with this in some clever way. Do I need to assign an exit code or something, and would that involve overriding the default shell parameters in Jenkins?
Any help much appreciated.
I think you would need to put a try/catch around the shell (so run it in a script{} block), and do your email in the catch. Then you can keep the build set to SUCCESS.
I actually solved this in a slightly different manner to #Rob's suggestion, but the key to it was understanding that what I wanted to do needed to use the script block with the returnStatus flag. I prefer this to a try-catch, as I am actually expecting (unfortunately) this to fail from time to time, and so would prefer to branch this below.
stage ('Serenity') {
steps {
script{
// For the Delivery CI build don't fail on regression failure
def bddPassed = ( sh ( returnStatus:true, script:'mvn clean verify -pl regression -DskipCuke=false') == 0 )
if( !bddPassed ){
echo 'There are regression suite failures.'
def mySubject = "Regression Test Failure: ${env.JOB_NAME} - Build# ${env.BUILD_NUMBER}"
def myBody = "Hi<br/>Please go to <a href='${env.BUILD_URL}Serenity'>the Serenity Report</a> to see more<br/>";
emailext attachLog: true,
mimeType: 'text/html',
body: myBody,
compressLog: true,
recipientProviders: [[$class: 'CulpritsRecipientProvider']],
subject: mySubject,
to: 'xxxxxxx'
}
publishHTML([allowMissing: true, alwaysLinkToLastBuild: true,
keepAll: true, reportDir: 'regression/target/site/serenity', reportFiles: 'index.html',
reportName: 'Serenity', reportTitles: ''])
}
}
}

WebStorm does not recognize `browser`, `element` etc in Protractor test spec

Following Protractor guide I wanted to create my first test. While the test works unfortunately JetBrains WebStorm does not recognize all of my variables in given test
I have enabled in Libraries/JavaScript:
jasmine
karma
karma-jasmine
HTML
Node.js Core
selenium-webdriver
As seen above Node.js Core library is enabled.
I have also visited this question but unfortunately the angular-protractor is no longer available.
What am I missing?
Your editor will understand it if its imported. Elese it will know where to find browser ot by
Add import statement at top of your file.
import {by, element} from 'protractor';
Use JS Hint RC. It will work like magic.
You can find this by going to
Settings -> Languages and Frameworks -> Javascript(select ECMA Script 6) ->Code Quality Tools- >JS Hint - Enable, use config file.
As for config file, save the bellow file, with following name: '.jshintrc'.
Rate the answer as positive if this worked for you!
{
"jasmine": true,
"mocha": true,
"esversion":6,
"loopfunc": true,
"node": true,
"globals": {
"esversion": 6,
"angular": false,
"browser": false,
"inject": false,
"_": false,
"driver": false,
"protractor": false,
"$": false,
"$$": false,
"element": false,
"by": false,
"list": false
}
}

Jenkinsfile conditions in Stage phase

should it possible to define several conditions in a Stage phase of Jenkins file??
Let me to explain my problem: I want to publishHtml in my Jenkins pipeline only if a condition is valid:
stage(Documentation)
{
agent any
steps
{
sh"./documents.sh " //This generate the documentation of several modules
if(firstModule) { //Is it possible to publishHTML only if documentation of this module was generated???
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "${env.WORKSPACE}/firstModule//html",
reportFiles: 'index.html',
reportName: "Fist Module Documentation"
])
}
if(secondModule) { //Is it possible to publishHTML only if documentation of this module was generated???
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "${env.WORKSPACE}/secondModule/html",
reportFiles: 'index.html',
reportName: "Second Modul Documentation"
])
}
}
I don't know if firstModule was built or not... this is what I would like to know.
I don't want to create different stages, but just one "Documentation" visible in the jenkins view.
Thank for your suggestion.
Prisco
it sounds like you want to publish documentation for firstModule only if "${env.WORKSPACE}/firstModule/html/index.html exists.
instead of:
if(firstModule) {
try:
script {
if (fileExists("${env.WORKSPACE}/firstModule/html/index.html")) {
# publishHTML and whatnot
}
}

Resources