Import .png as .imageset to Xcode assets on Jenkins pipeline - swift

Swift, Xcode macOs project
I have supported configuration of assets, basically all my assets are contained on remote repo,
I am using Jenkins as CI, in one of the stages I clone all the contents of config-repo to PROJ/Resources/Assets.xcassets
Script example:
sh 'cp -a configuration/meta_configuration/assets PROJ/Resources/Assets.xcassets || echo "copy failed"'
(configuration is cloned dir of config-repo)
So now I have to make my config team to create folders inside /meta_configuration/assets folder using template: asset_name.imageset - Config.json inside it: add one - three .png files, add them to .json and upload into the directory.
I am looking for some way of automatically create .imageset from given .png (Jenkins pipeline script maybe) and overall advice how we should approach this step as currently we experiencing that a lot of footwork is needed to add/support assets into the repo.
Q: How to automatically create .imagest from given .png file(s)?
edit: added project specs

Related

Rename file in Azure Devops Pipeline

I have a situation where I need to deploy different stylesheets to different environments (Dev/Test etc).
Is there a way I can edit the publish artefact so I can do a release pipeline for each environment?
So I would have a build pipeline that produces theused.css, dev.css,
test.css
I would have a release pipeline for Dev & Test
The dev pipeline would edit the artefact by deleting theused.css then rename
dev.css to theused.css .. likewise for test
Or is there a better way to do this?
If I would want to rename a file I would probably write a bash/powershell script and execute it as a task in the pipeline.
Bash task
Power Shell Task
Specifically in your case I would copy/rename the dev.css/test.css to theused.css during the deployment step.
I do not know how you deploy but you could either rename the .css before the deployment to an S3 bucket for example or if you deploy on an on premise server copy the file and rename it at the same time.
cp /your/dev.css /your/deployed/path/to/theused.css #copying the file
mv /your/dev.css /your/deployed/path/to/theused.css #move/renaming the file
Meant to add this...
What I ended up doing was the following (with different configs, rather than css, but same idea):
In my app I have configs for Dev, Test & Prod (config.json, config-test.json, config-prod.json)
The first thing the app does is load the config when it runs
I build and deploy to dev
The build folder contains the build files including these config files
I have releases for Test and Prod that do the following:
Task 1: delete the config.json
Task 2: copy the appropriate config file, e.g. config-test in the test release pipeline, and rename it config.json
Task 3: deploy build files to the appropriate environment with the new config

How do I use an Azure DevOps Services Build Pipeline to retrieve TFVC source files based upon a Label value and then zip those files?

This is a TFVC repo in Azure, not Git. It is running in Azure DevOps Services, not local in Azure DevOps Server (2019). This is a classic pipeline, not YAML.
I got as far as adding a variable that contains the Label value I am looking to package into the zip file.
I can't figure out how to get the sources by Label value. In the Pipeline Get Sources step, I've narrowed the path down, but then I need to recursively get source files that have the Label in the variable I defined.
The next step is to zip those source files up, I've added an Archive task to which I will change the root folder from "build binaries" to the sources folder.
This is necessary for this particular project because we must pass the source files to the vendor as a zip for them to compile and install for us. The developers create/update the source files, build and test them locally, then apply a Label to the sources for a given push to the vendor.
When configuring 'Get sources' step, there is no any option or method that can only map the source files with the specified label.
As a workaround, in the pipeline job, you can try to add the steps to filter out the source files with the specified label, and use the Copy Files task to copy these files to a folder, then use the Archive Files task in this folder.
[UPDATE]
Normally, a pipeline run will automatically check out the file version (changeset) that triggers the run. If manually trigger the the pipeline, by default the run will check out the latest changeset if you do not specify one.
The labels are used to mark a version of a files or folders, so you also can get the specific version of files or folders via the labels.
In your case, you can try using the 'tf get' command to download the files with the specified labels.

What does "Package or folder" refer to in the File transform task in a release pipeline?

I'm completely new to Azure DevOps Pipelines so if I'm doing something incorrectly I'd appreciate a nod in the right direction... I setup a build pipeline and that seems to be working, now I'm trying to setup a release pipeline in order to run tests, it's mostly based on Microsoft's documentation:
https://learn.microsoft.com/en-us/azure/devops/test/run-automated-tests-from-test-hub?view=azure-devops
Before running tests I need to transform a config file to replace some variables like access keys, usernames, etc. What I setup is what I have below but for the life of me I can't figure out what text box Package or folder refers to. The documentation is super helpful as you can imagine:
File path to the package or a folder
but what package or what folder is this referring to??? I've tried several different things but everything errors with
##[error]Error: Nopackagefoundwithspecifiedpattern D:\a\r1\a\**\*.zip
or pretty much whatever I specify for a value.
The File Transform task supports the .zip files.
Test with the default File Transform task settings, I could reproduce this issue.
In Release pipeline, the file path could has one more node for the build artifacts .zip file.
The format example:
$(System.DefaultWorkingDirectory)\{Source alias name}\{Artifacts name}\*.zip
So you could try to set the $(System.DefaultWorkingDirectory)/**/**/*.zip in Package Or folder field
For example:
On the other hand, you can check the specific path in the Release log -> Download Artifacts Step.
$(System.DefaultWorkingDirectory): D:\a\r1\a
You could aslo use this specific path in the task.
Update:
If your file is Project Folder, you refer to the following sample:
File structure:
Task Settings:
Note:You only need to assign to the folder node.
You could also select the folder path via ... option.

Dynamic Bin folders hard to copy bin folder to artifact location Azure DevOps

I have a problem with my CI in Azure DevOps.
I need to have a generic PowerShell script run in each CI that copy files from the bin folder and put them to artifact(a) folder with each project folder name.
But bin path are dynamic e.g.
$projectBinDirectory\bin\release\net471\win-x64
$projectBinDirectory\bin\release\net471
$projectBinDirectory\bin\Release\netcoreapp2.1\win-x64
$projectBinDirectory\bin\Release\netcoreapp2.2\win-x64
$projectBinDirectory\bin\Release\netcoreapp2.1
in the future, if someone creates netcore 2.2 or something else how to configure publish path dynamically as I want to copy main project files
e.g.
copy from
bin\release\netcoreapp2.1\win-x64 all project *.dlls,*configs etc files
to
artifact\Projectname\ all project files
the issue
cannot figure out after bin\release\ path to reach to project files
I need to figure out what is the path dynamically after bin\release...\projectFiles
this argument fixed my issue
-c Release -o ./bin/$(BuildConfiguration)/publishNew:

Adding files to build package artifacts

I'm following a learning course on plural-sight and he shows an artifact with cfg folder and json file within that folder(outside of the packge.zip file) but I cant figure out how he managed to configure his build process to get that file there.
How do I achieve this and where should i go to learn more about package files how they are made?
Everything in the "drop" folder gets included in the default "Publish Build Artifacts" Task, just add your files in the drop folder (or subfolders there).
The variable with the path is called: $(Build.ArtifactStagingDirectory)
This images shows a newly created "Publish Build Artifacts" task:
Something similar is probably creating your artifact, check for it in your build definition.