Comments (8)
Only workaround I could think of was
DotNet.Test("*Test.csproj") with
{
DisplayName = "Dotnet Test",
TestRunTitle = "Title",
Arguments = "--no-build --configuration Release --collect \"Code coverage\"",
Inputs = new()
{
{ "ContinueOnError", parameters["myBool"] }
}
}
but this looks less ideal.
from sharpliner.
Hey,
Thanks for opening this issue. I agree that this is a very useful feature and should be supported. Unfortunately, I think it will require quite a bit of work as technically a variable can be put in place of basically anything. I think it might have a solution where we create a wrapper type that could be "T or expression" but I will have to do some experiments to verify it can be done.
I will get back to you soon about this.
from sharpliner.
I was also thinking a wrapper would be needed. Maybe something like Conditioned. I did notice also that the following syntax didn't seem to be supported either:
- task: DotNetCoreCLI@2
displayName: 'dotnet test'
inputs:
command: test
testRunTitle: "Title"
projects: |
*.Test.csproj
${{ if eq(parameters.myBool, true) }}:
arguments: 'some arguments'
${{ if eq(parameters.myBool, false) }}:
arguments: 'some other arguments'
Maybe one solution could cover both scenarios
from sharpliner.
Once you're in the Dictionary (like in inputs), this is actually possible:
StepTemplate("template1.yaml", new()
{
{ "some", "value" },
{
If.IsPullRequest,
new TemplateParameters()
{
{ "pr", true }
}
},
{ "other", 123 },
}),
from sharpliner.
Ah okay thanks! Though my key reason for using Sharpliner is to avoid dealing with yaml in the first place :D So I thought it could be cool if it was possible in another manner.
from sharpliner.
I agree completely.
I think we will end up wrapping all properties in a Conditioned<>
, yeah. For instance, now we have some like that already and some not.
For instance it's possible to do:
{
Pool = If..
}
But it wouldn't be possible for ContinueOnError
. So there is some debt in this where probably everything should be a Conditioned<>
. We could then make variable/parameter references (or expressions) implicitly cast into this as well, producing a string ${{ parameter.foo }}
.
However, there's one more angle to this - #122. This issue would mean wrapping all properties again so that we create a dictionary behind that we serialize. This would mean your C# and YAML would be ordered how you want and not how we decide in Sharpliner. So this is another one where we might potentially have to change dozens of properties. I need to consider both and whether it makes sense to do them together. But your issue has preference 100%. The order is not so important.
from sharpliner.
@mathiasi I was able to make this work using the Conditioned<>
everywhere. However, I still think we have some missing spots, e.g. using generic expressions everywhere. Something like this:
continueOnError: ${{ replace(parameters.someParameter, ' ', '') }}
But I think this should be possible to add with some new Expression()
method...
from sharpliner.
That was quick! 😄 Unfortunately I won't have the chance to try it out until a in couple of weeks but I definitely will!
from sharpliner.
Related Issues (20)
- The "PublishDefinitions" task failed unexpectedly in 1.5.0 HOT 6
- RepositoryResource doesn't serialize RepositoryType.Git HOT 10
- Missing a top level `pool` property on pipeline definition HOT 1
- Add support for each-expressions HOT 8
- Extends definition HOT 3
- Conditionally define `Arguments` for DotNetCoreCLI@2 task HOT 6
- Nested conditioned blocks (`if`, `each`...) not working
- Parameterize ExtendsPipelineDefinition to allow easier inheritance of PipelineWithExtends
- Make FlattenDefinition method on Conditioned public HOT 1
- Referencing a Sharpliner library project directly does not build
- Allow registration of custom validations via `SharplinerConfiguration`
- Allow overriding PipelineBase.Validation in subclasses outside of the Sharpliner project HOT 1
- Add models for PublishTestResults@2 and PublishCodeCoverageResults@1 ADO tasks
- DotNetInstallBuilder.FromGlobalJson() fails to set the useGlobalJson input HOT 1
- Add models for file operation tasks
- Make it easier to export new API
- Workspace = JobWorkspace.All result in error on DevOps Pipeline HOT 2
- How do I use runtime expressions? HOT 3
- Pwsh.Inline() Command HOT 2
- extension methods HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharpliner.