How to use a generated file by script in Bamboo as artifact - bamboo

I create a Python file to generate a json file with Bamboo script job. Now I need to upload the generated file to S3. How can I make it as artifact, from that I can reuse it in the next jobs?

To make Bamboo identify a json file as artifact, all you need to do is to define an artifact definition as described in the official documentation. This way, you can make Bamboo recognise the json file produced from the script task(/job?).
Then, make the artifact shareable as described on this page - Sharing artifacts so that next jobs can use them.

Related

replace tokens during release in azure devops

I have a release pipeline to deploy a asp.net core web app. This was created from a simple asp.net web deploy template on azure devops. The web deploy step just points to the .zip file of the artifact drop folder and deploys the app.
I would like to replace tokens in my appSettings.Staging.json file for example:
I am using Token Replace marketplace tool: https://github.com/qetza/vsts-replacetokens-task and setting it up in a pretty standard way as documented:
and setting up my variables in devops:
I would like the "DummyValue" to be replaced with "ActualValue".
Since the artifact is a zip file, I added the "File Extractor" task to unzip the the archive and then had Token Replace task target that folder. According to the logs, it seems like the Token Replace did end up replacing a value, but I can't access those resources directly to make sure.
Since I am now extracting files, I pointed the web deploy task to the new folder where the unarchived files reside, and it successfully deployed, but the resulting appsettings.Staging.json file still doesn't have the token replaced. In the logs of the deploy job I saw this:
2021-03-28T07:36:19.6554561Z Package deployment using ZIP Deploy initiated.
2021-03-28T07:38:08.8457706Z Successfully deployed web package to App Service.
Seems like it's still using ZIP deployment, and I am not sure where it's finding the zip file as there's nothing in the devops logs for that.
Just wondering if anybody else has experienced this and what the best way is to go with this.
It seems that you are using this extension: XDT Transform. After installing it in organization, there are 2 external tasks: XDT tranform task and Replace Tokens task in release pipeline.
There is appSettings.Staging.json file in my repo and it will be published into zip artifact.
In my release pipeline, the path to this artifact is $(System.DefaultWorkingDirectory)/Drop/drop/aspnet-core-dotnet-core.zip.
If I want to replace the DummyValue token in appSettings.Staging.json file of this artifact, creating pipeline variable DummyValue and using the Extract Files task, Replace Tokens task, and Archive Files task, finally the release will archive the replaced folders to replace original zip artifact, so it is done. so it is done. The unnecessary PowerShell task is used to output the replaced file.

Unable to use classpath or relative path to read json payload data

I have written a Karate scenario where my login is performed from a separate .feature file. I have the following directory structure:
src/test/java/feature/common/common.feature
When i want to call the above common feature file from another feature file which is in different folder (as below) it does not work:
src/test/java/feature/tests/test.feature
I have tried the following:
1.
callonce read('feature/common/common.feature')
and it does not work.
If i were to use classpath how would i write this call?
Using classpath: you will be able to access contents inside src/test/java if you follow standard karate workspace structure
Inorder to call / read,
* call read('classpath:feature/common/common. feature')
simply src/test/java can be replaced with classpath:
Refer reading files from karate document for more

How to have Bamboo artifacts collect a whole folders?

I have one simple plan with one simple job.
Tasks:
Source code checkout
MSBuild
Run tests
Generate test report
In four steps, my utility generates a test report with screenshots. The report contain absolute links to images. (for example: onclick="window.open('./Screenshots/66ef3a03-8b82-4b40-b49d-b0155e273738.png');return false;").
If I open the report on my local machine, the report works fine, but on Bamboo I receive the error "Page Not Found", because Bamboo has not collected "Screenshots" folder.
How can I set up the Artifact Definition to collect folder with files?
P.S. I tried to set the \*.* copy pattern, but Bamboo collected only files (without folders and subfolders)
You just have to give the folder Location, like "build/", for instance, and then, in the Copy Pattern you can put **/*.* That should copy all the files you want.
Please note that:
The location is relative to the build directory. Do not use the absolute path to refer to the location.
Asterisks are not supported for Location. For this field, provide the folder name where the file would be located.
Plus, you can define as many Artifact Definitions as you want.
The best way of doing this is to zip all you artifact together. I created a bash script to do this
cd "toArtifactFolder"
zip -r Artifact .
Then in bamboo project settings you have to edit the Artifact and changed the location to where ever the artifact zip file is
Then in the Copy Pattern just enter the zip file eg Artifact.zip
Bamboo uses the "Ant file copy pattern".
Matching recursively against all files: **/*
This does include almost everything
Unfortunately this does not include dot-files, at least in my test on a linux build agent. I could not find a workaround apart from a second artifact (pattern **/.*) or the creation of an archive.
Matching against all files in any subfolder: */*
This does not include foo/bar/test.xyz
This does include both foo/test.xyz and bar/test.xyz
You can do more advanced matching; e.g. you can use build/**/*.jar to copy all jars from a build directory.
For further info see the docs

Bamboo artifacts

I am very new to Bamboo. I have got a html file generated using log4j. I wish to put it in user-defined artifacts but don't know how.
It is in surefire-reports folder so I tried giving Source directory as "**/target/surefire-reports/" and Artifact Copy Pattern as "**/*.html" but it doesn't seems to work.
Any idea how to configure it?
Try to change copy pattern to
*.html
and verify your complete path.
I wanted to get all surefire reports from each module, so I created a new Artifact definition with:
Name = Surefire Reports
Location =
Copy Pattern = /target/surefire-reports/.*
This was using Bamboo 3.2.2.
The Location field does not provide the Ant file copy pattern feature, only a fixed path is accepted relative to the working directory.
Set the Location as target/surefire-reports
and the Copy pattern as **/*.html
Also make sure that the Shared checkbox is set, otherwise other jobs will not be able to download the artifact.

Teamcity 2 configurations merge and deploy

I have two teamcity configurations one becoming my common helpers and reuseable components and my other a website which uses the common project.
I use a third configuration to publish to a test environment.
When the third configuration is run i would like it to get the artifacts from the common project and merge them with the website output and deploy. Am i asking for two much?
This ought to be pretty straightforward.
On ThirdConfig add two artifact dependencies. One whose source is CommonProject, and another whose source is WebProject. When configuring an artifact dependency it will allow you to specify which artifact files are are actually pulled from CommonProject and WebProject into ThirdConfig via the 'Artifact paths'. The artifact files can then be placed into some new folder hierarchy specific to ThirdConfig by using the 'Destination path'. These two options ought to be enough to create the directory structure that is the merging of CommonProject and WebProject. That takes care of the merge part.
The deploy is a bit more tricky. To my knowledge TeamCity does not support any sort of 'copy or upload to external location' function out of the box. For this bit you'll need to create an msbuild script (or batch file, or anything that can be run from the command line). Said script can expect the file/directory structure you've created via artifact dependencies where the root of the structure is the initial working directory of the script, and need only push these files out to your specific deploy location. That 'push' of course is going to be specific to your environment. Ftp, unc share, etc.