I have an HTMl report that needs to be viewable from the Jenkins dashboard. The report is getting archived successfully as indicated in the console output though. My script looks like:
post {
always {
archiveArtifacts '**/target/*.tar.gz'
publishHTML([allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: 'target',
reportFiles: 'dependency-check-report.html',
reportName: 'OWASP Dependency Check Report',
reportTitles: ''
])
}
Related
I've defined the following step in a JenkinsFile which generates an html report while running the Jenkins pipeline:
stage('Run Integration Tests') {
steps {
dir("${env.WORKSPACE}/test/integration") {
sh'''
npm install -g newman
npm install -g newman-reporter-htmlextra
newman run postman_collection.json -e ''' +APIGEE_ENVIRONMENT+'''.postman_environment.json --reporters cli,htmlextra --reporter-htmlextra-export "newman_result.html"
'''
}
}
}
I then try to publish this report, but whatever I try, it doesn't show the report but instead shows an empty html page. I'm probably messing something up in the configuration but I'm stuck on this for several hours now. I hope anyone finds the missing piece. Thank you so much in advance.
stage('Artifacts') {
steps {
publishHTML(target: [
alwaysLinkToLastBuild: false,
allowMissing: false,
keepAll: true,
reportDir: "${WORKSPACE}",
reportFiles: 'newman_result.html',
reportName: 'Integration Test Results',
reportTitles: ''
])
}
}
turns out the issue was with the reportDir. The report was being generated in folder /test/integration so I had to change the reportDir attribute to:
reportDir: "${WORKSPACE}/test/integration",
[htmlpublisher] Archiving HTML reports...
[htmlpublisher] Archiving at BUILD level /home/jenkins/workspace/awesome-integration-into-jenkins/mochawesome-report to
/var/jenkins_home/jobs/IDE/jobs/ide-application/branches/subtask-I.anjt14c4kifi.o-jenkins/builds/5/htmlreports/Mochawesome_20Report
This output is obtained after running:
post {
always {
sh 'rm mochawesome-report/mochawesome.json'
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: "$WORKSPACE/mochawesome-report/",
reportFiles: 'mochawesome.html',
reportName: "Mochawesome Report"
])
cleanWs()
}
}
I am using htmlpublisher to publish test report after all steps in the pipeline are complete. As can be seen from the output, the files are copied to var/jenkins_home/jobs/IDE/jobs/mosaiq-ide-application/branches/subtask-I.anjt14c4kifi.o-jenkins/builds/BUILDNUMBER/. There is no setting in htmlpublisher that allows the user to delete old report folders. Is there a plugin that I can use in the post pipeline step that looks inside the ..../builds/BuildNumber/htmlreports folder and checks if it is x days old, and removes it. Or how can I efficiently achieve the desired result?
I have a Jenkinsfile that deploys my angular app code to a site using the Publish over FTP plugin. All of the files in the dist folder are transferred except an assets subfolder. I have tried putting in the following values for the sourceFiles parameter with no success: 'webapp/dist/', 'webapp/dist/**', 'webapp/dist/**/*'.
Here is the publish over FTP part of my Jenkinsfile:
stage('Deploy') {
steps {
echo 'Deploying....'
ftpPublisher paramPublish: null, masterNodeName:'', alwaysPublishFromMaster: true, continueOnError: false, failOnError: true, publishers: [
[configName: 'Angular app', verbose: true, transfers: [
[asciiMode: false, cleanRemote: true, makeEmptyDirs:true, excludes: '', flatten: false,
noDefaultExcludes: false, patternSeparator: '[, ]+',
remoteDirectory: "webapp",
removePrefix: "webapp/dist",
remoteDirectorySDF: false,
sourceFiles: 'webapp/dist/**/*']
], usePromotionTimestamp: false, `enter code here`useWorkspaceInPromotion: false]
]
}
}
I've looked at the Publish over FTP pipeline documentation: https://jenkins.io/doc/pipeline/steps/publish-over-ftp/ and couldn't find anything parameters that I was missing. I'm stuck.
I was able to solve the issue. I changed the title of the pipeline to all lowercase letters without any spaces. I then changed the file path of the workspace folder to 'C:/jenkinsworkspace/${ITEM_FULL_NAME}' by modifying the workspaceDir entry in the config.xml located in the Jenkins root directory. I stopped the Jenkins service before modifying the config.xml. Both the assets folder and the favicon got generated in the build. It was one of the solutions mentioned in https://github.com/angular/angular-cli/issues/9230. Thanks for your help #Alberto L. Bonfiglio.
i have another question about the jenkins pipeline.
How can i publish the build artifacts to a windows share? In normal build jobs there is a "CIFS Publisher" post build action. But how can i use it in
post{
success {
//publish build artifacts
}
}
Is there any example?
I've succesfully managed it in this way:
cifsPublisher alwaysPublishFromMaster: false, continueOnError: false, failOnError: false, publishers: [[
configName: 'NAME_OF_THE_CIFS_CONFIG', transfers: [[
cleanRemote: false,
excludes: '',
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: '$BUILD_NUMBER',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'myfile']],
usePromotionTimestamp: false,
useWorkspaceInPromotion: false,
verbose: true
]]
Please use the auto generate tool in Jenkins to help you.
As you can see the highlight link. Click it.
Fill all the required value that you expected.
After scroll down and click Generate pipeline script, you will see the syntax that you need.
Last step, copy the generated script into success clause.
I am using the HTML publisher plugin and I am generating html report and placing in a report folder report/profile.html. I have specified the path where my report is in HTML directory to archive. I gave the path as /apps/cmjenkins/workspace/service_testapps_copy/LISA Project/Mezzo_Automation/Reports. That gave directory does not exist error so gave the complete path as well: C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports
Below is the error i see in console output after i run my jenkins build
12:45:34 [htmlpublisher] Archiving HTML reports...
12:45:34 [htmlpublisher] Archiving at PROJECT level C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports to /var/lib/jenkins/jobs/API_PROFILE_HTML_Report_POC/htmlreports/HTML_Report
12:45:34 ERROR: Specified HTML directory 'C:/Users/dtiker/Documents/Feb24/universe1_0_testapps/service_testapps/LISA Project/Mezzo_Automation/Reports' does not exist.
12:45:34 Build step 'Publish HTML reports' changed build result to FAILURE
12:45:34 Finished: FAILURE
I verified that that directory does exist. Can someone let me know what i am doing wrong?
Your job (each node{}) will use an own workspace, you should always reference files of the current build with a relative path!
publishHTML(reportDir: 'reports', reportFiles: 'profile.html'])
In my case misconfiguration of HTML publisher caused the problem
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: false,
includes: '**/*.png', <--------------------- this line
keepAll: true,
reportDir: 'reports/',
reportFiles: 'friday_health_broker_portal_uat_index.html',
reportName: 'HTML Report',
reportTitles: 'FH BP'
])
Once I changed it includes to includes: '**/*' the problem was gone
when I used file path in "filepath " instead of 'filepath ', then its working fine for me
stage ('publish results') {
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: true,
keepAll: false,
reportDir: "/var/lib/jenkins/workspace/project/target/site/serenity",
reportFiles: "index.html",
reportName: 'HTML Report',
reportTitles: ''
])
}