I am trying to customize mocha-bamboo-reporter https://www.npmjs.com/package/mocha-bamboo-reporter, in my protractor tests, to include a field named file, which includes the test file name in bamboo reports.
mocha-bamboo-reporter
var o = {
title: test.title
, fullTitle: test.fullTitle()
, duration: test.duration
, file: test.file // this is the new change
};
When i run the tests locally the generated mocha.json includes the file info that i want.
mocha.json
{
"title": "should show login form",
"fullTitle": " Home Page should show login form",
"duration": 300,
"file": "xxx/tests/directory-name/test.js"
},
In Bamboo I have a Mocha Test Parser build task for mocha.json, but in the bamboo reports file is never included, only title, fullTitle, duration etc. What do i need to do to get this info to show? Do i need to include something in mochaBambooReporterReporterOptions?
Bamboo Build Task
Related
Currently working on a react app and I'm getting this error after installing metaplex.
My react-scripts version is 4.0.3
./node_modules/#metaplex-foundation/js-next/dist/esm/programs/token/gpaBuilders/TokenGpaBuilder.mjs
Can't import the named export 'ACCOUNT_SIZE' from non EcmaScript module (only default export is available)
I found out the solution in the git of metaplex here. I will leave you here the whole answer anyway.
Getting Started with Metaplex and CRA 5
This example sets up a new React app with Metaplex using "Create React App" (CRA) version 5 — i.e. using Webpack 5.
This example has been generated using the following steps:
Create a new project using the "Create React App" command.
npx create-react-app getting-started-react-cra5
cd getting-started-react-cra5
Install the Metaplex and the Solana SDKs.
npm install #metaplex-foundation/js #solana/web3.js
Install some polyfills.
npm install assert util crypto-browserify stream-browserify
Install and use react-app-rewired.
# Installs react-app-rewired.
npm install react-app-rewired
# Replaces "react-scripts" with "react-app-rewired" in package.json scripts.
sed -i '' 's/react-scripts /react-app-rewired /g' package.json
Override Webpack 5 configurations.
Create a new file to override Webpack 5 configurations.
touch config-overrides.js
Copy the following code inside the new config-overrides.js file.
const webpack = require("webpack");
module.exports = function override(webpackConfig) {
// Disable resolving ESM paths as fully specified.
// See: https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
webpackConfig.module.rules.push({
test: /\.m?js/,
resolve: {
fullySpecified: false,
},
});
// Ignore source map warnings from node_modules.
// See: https://github.com/facebook/create-react-app/pull/11752
webpackConfig.ignoreWarnings = [/Failed to parse source map/];
// Polyfill Buffer.
webpackConfig.plugins.push(
new webpack.ProvidePlugin({ Buffer: ["buffer", "Buffer"] })
);
// Polyfill other modules.
webpackConfig.resolve.fallback = {
crypto: require.resolve("crypto-browserify"),
stream: require.resolve("stream-browserify"),
util: require.resolve("util"),
assert: require.resolve("assert"),
fs: false,
process: false,
path: false,
zlib: false,
};
return webpackConfig;
};
Update your browser requirements.
Update the browserslist object of your package.json to include the following production requirements.
"browserslist": {
"production": [
- ">0.2%",
- "not dead",
- "not op_mini all"
+ "chrome >= 67",
+ "edge >= 79",
+ "firefox >= 68",
+ "opera >= 54",
+ "safari >= 14"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
That's it!
You should not use #metaplex-foundation/js-next SDK, the actual repo is #metaplex-foundation/js, the name was changed and the updated repo is this, so try using #metaplex-foundation/js instead
I have developed a bot using Bot Framework. It shows images when I run it locally on the Bot Framework Emulator. But after publishing it on Azure by creating a private GitHub repository, none of the images are displayed. I'm using Direct-Line API 3.0. What could be the reason?
Like, here's the tree-view of my project. The images folder resides in Content Root.
I'm using the following static method to retrieve an image path.
public static string CreateImagePath(string filename)
{
return Path.Combine(TempData.HostingEnvironment?.ContentRootPath, "images", $"{filename}");
}
And then converting it into a Uri, and assigning it to an Adaptive Card's image. Here's the code snippet.
(AdaptiveCardFactory.CreateAdaptiveElement(card, "image") as AdaptiveImage).Url =
new Uri(PathFactory.CreateImagePath("welcome_card_image.png"));
CreateAdaptiveElement is defined as:
public static AdaptiveElement CreateAdaptiveElement(AdaptiveCard card, string adaptiveElementId)
{
return card.Body.Find(ae => ae.Id == adaptiveElementId);
}
This is the Uri that is returned when I run the bot locally. it works fine.
file:///C:/Users/Husai/source/repos/PanjaSahibBot/images/welcome_card_image.png
Here's what is returned after publishing.
file:///D:/home/site/wwwroot/images/welcome_card_image.png
And, it's not working.
Here's the latest command log.
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling ASP.NET Core Web Application deployment.
Restoring packages for D:\home\site\repository\GurdwaraBot.csproj...
Generating MSBuild file D:\home\site\repository\obj\GurdwaraBot.csproj.nuget.g.props.
Generating MSBuild file D:\home\site\repository\obj\GurdwaraBot.csproj.nuget.g.targets.
Restore completed in 5.02 sec for D:\home\site\repository\GurdwaraBot.csproj.
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 1.41 sec for D:\home\site\repository\GurdwaraBot.csproj.
GurdwaraBot -> D:\home\site\repository\bin\Release\netcoreapp2.2\GurdwaraBot.dll
GurdwaraBot -> D:\local\Temp\8d6da8df6d390f3\
Creating app_offline.htm
KuduSync.NET from: 'D:\local\Temp\8d6da8df6d390f3' to: 'D:\home\site\wwwroot'
Copying file: 'GurdwaraBot.deps.json'
Copying file: 'GurdwaraBot.dll'
Copying file: 'GurdwaraBot.pdb'
Copying file: 'GurdwaraBot.runtimeconfig.json'
Copying file: 'images\01d.png'
Copying file: 'images\01n.png'
Copying file: 'images\02d.png'
Copying file: 'images\02n.png'
Copying file: 'images\03d.png'
Copying file: 'images\03n.png'
Copying file: 'images\04d.png'
Copying file: 'images\04n.png'
Copying file: 'images\09d.png'
Copying file: 'images\09n.png'
Copying file: 'images\1.jpg'
Copying file: 'images\10.jpg'
Copying file: 'images\10d.png'
Copying file: 'images\10n.png'
Copying file: 'images\11d.png'
Copying file: 'images\11n.png'
Copying file: 'images\13d.png'
Copying file: 'images\13n.png'
Copying file: 'images\2.jpg'
Copying file: 'images\3.jpg'
Copying file: 'images\4.jpg'
Copying file: 'images\5.jpg'
Copying file: 'images\50d.png'
Copying file: 'images\50n.png'
Copying file: 'images\6.jpg'
Copying file: 'images\7.jpg'
Copying file: 'images\8.jpg'
Copying file: 'images\9.jpg'
Copying file: 'images\bill.png'
Copying file: 'images\feedback.png'
Copying file: 'images\Festivals.jpg'
Copying file: 'images\festivals_bandi_chhor_divas.jpg'
Copying file: 'images\festivals_gurpurab.jpeg'
Copying file: 'images\festivals_hola_mohalla.jpg'
Copying file: 'images\festivals_maghi.jpg'
Copying file: 'images\festivals_martyrdom_of_guru_arjan.jpg'
Copying file: 'images\festivals_parkash_utsav_dasveh_patshah.jpg'
Copying file: 'images\festivals_vaisakhi.jpg'
Copying file: 'images\menu_card_image.png'
Copying file: 'images\panja_thumbnail_1.png'
Copying file: 'images\panja_thumbnail_2.png'
Copying file: 'images\panja_thumbnail_3.png'
Copying file: 'images\pof_guest_hotel.jpg'
Copying file: 'images\question.png'
Omitting next output lines...
Finished successfully.
This is what I am expecting.
Locally executed
And, this is what I'm getting via DirectLine!!
Actual result
Here's the content of my welcome_card.json
{
"type": "AdaptiveCard",
"body": [
{
"type": "Image",
"id": "image",
"horizontalAlignment": "Center",
"style": "Person",
"url": "",
"size": "Medium"
},
{
"type": "TextBlock",
"horizontalAlignment": "Center",
"size": "Medium",
"weight": "Bolder",
"color": "Accent",
"text": "Welcome to Gurdwara Bot",
"wrap": true
},
{
"type": "TextBlock",
"horizontalAlignment": "Left",
"text": "Hi there! I'm the Sri Panja Sahib's support bot. What can I help you with today? Just so you know, you can enter **MENU** anytime you want to go back to the options below, or just go ahead type your query.",
"wrap": true
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Get an Overview",
"data": {
"dataId": "overview"
}
},
{
"type": "Action.Submit",
"title": "Ask a Question",
"data": {
"dataId": "question"
}
},
{
"type": "Action.Submit",
"title": "Book a Room",
"data": {
"dataId": "room"
}
},
{
"type": "Action.Submit",
"title": "Give a Feedback",
"data": {
"dataId": "feedback"
}
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0",
"speak": "Hi there! I'm the Sri Panja Sahib's support bot. What can I help you with today? Just so you know, you can enter **MENU** anytime you want to go back to the options below, or just go ahead type your query."
}
I've defined AdaptiveCardFactory to manipulate with cards.
public class AdaptiveCardFactory
{
public static AdaptiveCard CreateAdaptiveCard(string path)
{
try
{
var adaptiveCardJson = File.ReadAllText(path);
AdaptiveCardParseResult result = AdaptiveCard.FromJson(adaptiveCardJson);
return result.Card;
}
catch (AdaptiveSerializationException)
{
throw;
}
}
public static Attachment CreateAdaptiveCardAttachment(AdaptiveCard card)
{
return new Attachment
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = card,
};
}
public static AdaptiveElement CreateAdaptiveElement(AdaptiveCard card, string adaptiveElementId)
{
return card.Body.Find(ae => ae.Id == adaptiveElementId);
}
}
TL;DR;
You must provide public URLs for items displayed in AdaptiveCards, not local ones. It is working in local with the emulator because... you are in local, and the emulator has access to your local files, so it can understand files with local location (C:\... or D:\... files).
So change your path so that it uses your sub-domain: you can do it here, for example by using a configuration variable instead of TempData.HostingEnvironment?.ContentRootPath
public static string CreateImagePath(string filename)
{
return Path.Combine(TempData.HostingEnvironment?.ContentRootPath, "images", $"{filename}");
}
Details:
AdaptiveCard item is passed as an attachment in the bot message, everything that is inside is rendered by the client (channel), so it can only render things that are "visible" from the outside.
See my demo here: I used a Card with an ImageSet of 2 images: one with an URL over the web, the other with an URL build like yours.
Local: both images are OK.
Published: only 1st image is displayed
If you look at the Inspector on the right-side, it becomes obvious that you must change the way you build your image Url.
You can also have a look to your deployed webchat by right-clicking the zone where the image should be, and you will find a link with a D:\... path
Code Fix
1st, move your images folder inside wwwroot folder of your projet. Then you can do the following:
public string CreateImagePath(string filename)
{
if (_hostingEnvironment.IsDevelopment())
{
return Path.Combine(TempData.HostingEnvironment?.ContentRootPath, "wwwroot", "images", $"{filename}");
}
else
{
var targetUri = new Uri(new Uri($"https://{Environment.ExpandEnvironmentVariables("%WEBSITE_SITE_NAME%")}.azurewebsites.net"), Path.Combine("images", $"{filename}"));
return targetUri.ToString();
}
}
I am trying to send HTML file in email body itself (not attachment). I have written Jenkins declarative pipeline as follows
post {
always {
presendScript: "def reportPath=build.getWorkspace().child("target/serenity-summary.html")
msg.setContents(reportPath.readToString(), "text/html")"
emailext attachmentsPattern: "Serenity_Test_Results${env.BUILD_NUMBER}.zip" ,
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} More info at: ${env.BUILD_URL}Unzip the attached document and click on index.html to view complete test results",
subject: "API Testing: Jenkins Job Results - Build # ${env.BUILD_NUMBER} - Failed",
mimeType: 'text/html',to: "xyz#abc.com"
}
}
I am getting error as follows
WorkflowScript: 30: expecting anything but ''\n''; got it anyway # line 30, column 102.
target/serenity-summary.html")
^
1 error
I need to attach the HTML file to email body itself and I need proper presend script in post section.
I think you made a wrong usage of pipeline step emailext. You can try as following.
post {
always {
emailext(
to: "xyz#abc.com",
mimeType: 'text/html',
attachmentsPattern: "Serenity_Test_Results${env.BUILD_NUMBER}.zip",
subject: "API Testing: Jenkins Job Results - Build # ${env.BUILD_NUMBER} - Failed",
presendScript: 'def reportPath=build.getWorkspace().child("target/serenity-summary.html");msg.setContents(reportPath.readToString(), "text/html")',
body: "${currentBuild.currentResult}: Job ${env.JOB_NAME} build ${env.BUILD_NUMBER} " +
"More info at: ${env.BUILD_URL}Unzip the attached document and click on index.html to view complete test results"
)
}
}
I'm trying to run a pipeline that does some Pester Testing and publish the NUnit results.
New tests were introduced and for whatever the reason, Jenkins no longer publishes the test results and errors out immediately after the powershell script. Hence, it doesn't get to the nunit publish piece. I receive this:
ERROR: script returned exit code 128
Finished: FAILURE
I've been trying to include the publish in the always section of the post section of the Jenkinsfile, however, I'm running into problems on how to make that NUnit test file available.
I've tried establishing an agent and unstash the file (even though it probably won't stash if the powershell script cancels the whole pipeline). When I use agent I get the following exception:
java.lang.NoSuchMethodError: No such DSL method 'agent' found among steps
Here is the Jenkinsfile:
pipeline {
agent none
environment {
svcpath = 'D:\\svc\\'
unitTestFile = 'UnitTests.xml'
}
stages {
stage ('Checkout and Stash') {
agent {label 'Agent1'}
steps {
stash name: 'Modules', includes: 'Modules/*/**'
stash name: 'Tests', includes: 'Tests/*/**'
}
}
stage ('Unit Tests') {
agent {label 'Agent1'}
steps {
dir(svcpath + 'Modules\\'){deleteDir()}
dir(svcpath + 'Tests\\'){deleteDir()}
dir(svcpath){
unstash name: 'Modules'
unstash name: 'Tests'
}
dir(svcpath + 'Tests\\'){
powershell """
\$requiredCoverageThreshold = 0.90
\$modules = Get-ChildItem ../Modules/ -File -Recurse -Include *.psm1
\$result = Invoke-Pester -CodeCoverage \$modules -PassThru -OutputFile ${unitTestFile} -OutputFormat NUnitXml
\$codeCoverage = \$result.CodeCoverage.NumberOfCommandsExecuted / \$result.CodeCoverage.NumberOfCommandsAnalyzed
Write-Output \$codeCoverage
if (\$codeCoverage -lt \$requiredCoverageThreshold) {
Write-Output "Build failed: required code coverage threshold of \$(\$requiredCoverageThreshold * 100)% not met. Current coverage: \$(\$codeCoverage * 100)%."
exit 1
} else {
write-output "Required code coverage threshold of \$(\$requiredCoverageThreshold * 100)% met. Current coverage: \$(\$codeCoverage * 100)%."
}
"""
stash name: 'TestResults', includes: unitTestFile
nunit testResultsPattern: unitTestFile
}
}
post {
always {
echo 'This will always run'
agent {label 'Agent1'}
unstash name: 'TestResults'
nunit testResultsPattern: unitTestFile
}
success {
echo 'This will run only if successful'
}
failure {
echo 'This will run only if failed'
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}
Any and all input is welcome! Thanks!
The exception you are getting is due to Jenkins' strict pipeline DSL. Documentation of allowable uses of agent are here.
Currently agent {...} is not allowed to be used in the post section. Maybe this will change in the future. If you require the whole job to run on the node that services label 'Agent1' the only way to currently do that is to
Put agent {label 'Agent1'} immediately under pipeline { to make it global
Remove all instances of agent {label 'Agent1'} in each stage
Remove the agent {label 'Agent1'} from the post section.
The post section acts more like traditional scripted DSL than the pipeline declarative DSL. So you have to use node() instead of agent.
I believe I've had this same question myself, and this SO post has the answer and some good context.
This Jenkins issue isn't exactly the same thing but shows the node syntax in the post stage.
I am trying to create a custom image in my Azure DevTestLab, from a vhd image stored in the default storage account.
I started modifying the file at the GitHub repo for ARM templates for creating a custom image from a vhd.
I have already created the DevTest lab, and I can run the following Powershell command to get its data:
PS C:\git> $rid = Get-AzureRmResource -ResourceGroupName jgTl9-rg -ResourceType Microsoft.DevTestLab/labs -ResourceName jgTl9 -ApiVersion 2016-05-15
This yields a bunch of information. If I want to extract the default storage account name, I do the following:
PS C:\git> $rid.properties.defaultStorageAccount
So I know it's possible to get it. Now I have modified the variables section of the Azure build template (a JSON file) to look as follows:
"variables": {
"resourceName": "[concat(variables('existingLabName'), '/', variables('imageName'))]",
"resourceType": "Microsoft.DevTestLab/labs/customimages",
"existingLabName": "[replace(resourceGroup().name,'-rg','')]",
"storageAccountID": "/subscriptions/xxxxxxxxxxxx/resourceGroups/jgTl9-rg/providers/Microsoft.Storage/storageAccounts/djgtl91795",
"saidFrags": "[skip(split(variables('storageAccountID'), '/' ), add(length(split(variables('storageAccountID'), '/' )),-1) ) ]",
"storageAccountSuffix": "[take(variables('saidFrags'),1)[0]]",
"existingVhdUri": "[concat('https://',variables('storageAccountSuffix'),'.blob.core.windows.net/uploads/',parameters('imageFileName'))]",
"imageName": "JaysImage"
},
This code actually works when I call the New-AzureRmResourceGroupDeployment command with the azuredeploy.json and azuredeploy.parameters.json.
However, instead of hardcoding the storageAccountID variable, I'd like to extract the defaultStorageAccount from the environment. I tried something like this:
"storageAccountID": "[string( resourceId(resourceGroup().name,'MicrosoftDevTestLab/labs','jgTl9').properties.defaultStorageAccount ))",
I tried a few variations on this but nothing worked. What is the syntax I need to use to extract the same information as I have hardcoded for the storageAccountID?
(I could not find anything in Microsoft's description of template functions).
Couple of issues with your following expression
"storageAccountID": "[string( resourceId(resourceGroup().name,'MicrosoftDevTestLab/labs','jgTl9').properties.defaultStorageAccount ))",
There is syntax issue ie. an extra ) at the end.
The resource provider MicrosoftDevTestlab/labs should be Microsoft.DevTestlab/labs
When resourceId is used it will not give you the entire object. So when you do properties.defaultStorageAccount it will not work. Because it gives you just the string of your dev test lab and nothing else and there is no property on a string of defaultStorageAccount.
Now what you need is reference function like below
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
"vDefaultStorageAccount": "[string(resourceId('yourResourceGroupName','Microsoft.DevTestLab/labs','yourTestLabName'))]"
},
"resources": [],
"outputs": {
"defaultStorageAccount":{
"value": "[reference(variables('vDefaultStorageAccount'),'2016-05-15').defaultStorageAccount]",
"type":"string"
}
}
}
In the variable, vDefaultStorageAccount we get the ID of the DevTestLab and then we use reference function to get the object. Then you can do . to get properties. You don't need to do properties.defaultStorageAccount for example.