Comments (33)
Yes, it's on our short backlog to create a cli
from azure-pipelines-yaml.
@vtbassmatt This works great, I made a powershell cmdlet for it.
https://gist.github.com/JustinGrote/4ece827540da00d5ffce1d9eb593e56c
One thing: The most useful thing for this would be testing templates to make sure they expand properly. Is there any way in the YamlOverride to specify multiple files or somehow test templates?
from azure-pipelines-yaml.
We have shipped a server-side API for this. No plans to ship a fully standalone version, though, because the amount of server logic we would have to reimplement is too great.
POST to dev.azure.com/<org>/<project>/_apis/pipelines/<pipelineId>/runs?api-version=5.1-preview
with a JSON body like this:
{
"PreviewRun": true,
"YamlOverride": "
# your new YAML here, optionally
"
}
The response will contain the rendered YAML.
from azure-pipelines-yaml.
@4c74356b41 Build - read & execute
from azure-pipelines-yaml.
@JustinGrote Any plans on publishing this to PowerShell modules gallery?
+1 on multi-file support as we heavily use YAML templates
from azure-pipelines-yaml.
@vtbassmatt thank you, and FYI while this is a welcome change, the inability to resolve/test templates (which requires a separate file unless theres some magic you can bestow upon me) kinda limits its usefulness, since expanding ${{ each and ${{ if statements is my primary big use case for this vs. commit over-and-over.
from azure-pipelines-yaml.
FYI, related pull request to add this to the VSTeam Powershell Module
MethodsAndPractices/vsteam#272
from azure-pipelines-yaml.
+1 on this - Preferably via a CLI which we can pull in via NPM and maybe even a Azure DevOps task as well.
from azure-pipelines-yaml.
Did this ever get built?
from azure-pipelines-yaml.
That's a good tool indeed and would certainly help!
However, a standalone tool is a must as it should be able to run as part of a CI build.
from azure-pipelines-yaml.
No plans to implement a task. By default, the build identity doesn't have permissions to queue a dry-run build. But if you alter that, it's a relatively short shell script:
pool:
vmImage: ubuntu-latest
steps:
- checkout: none
- bash: |
RUNS_URL=${SYSTEM_TEAMFOUNDATIONCOLLECTIONURI}${SYSTEM_TEAMPROJECT}/_apis/pipelines/${SYSTEM_DEFINITIONID}/runs?api-version=5.1-preview
echo $RUNS_URL
curl --user PAT:$(System.AccessToken) \
-sS \
--header "Content-Type: application/json" \
--request POST \
--data '{"PreviewRun": true,"YamlOverride":"steps:[{checkout:none}]"}' \
$RUNS_URL
(Obviously replacing the payload with your chosen YAML.)
from azure-pipelines-yaml.
@JustinGrote that cmdlet is great, thanks for sharing! We don't have a multi-file version of this endpoint right now, but feature request noted.
from azure-pipelines-yaml.
We are also using templates heavily, but have centralised them in a single repository. I've now setup a build pipeline for that repository to validate all the YAML pipelines that use that repository with the new changes being made to it. This allows us to validate the changes before merging them which could potentially break all our pipelines. Not anymore with this feature which is nice. Maybe I should write a blog post ;).
from azure-pipelines-yaml.
@tomkerkhove it looks like @SebastianSchuetze is going to add it to the https://github.com/DarqueWarrior/vsteam module based on a twitter exchange we had :)
from azure-pipelines-yaml.
So I've been testing this out and this seems to only work if your entire pipeline definition is in a single file, and/or you are only trying to validate the pipeline entry point file, which doesn't work for us. We generally use templates, and as soon as you do that, it doesn't seem like it's possible for those to be picked up. If I make a typo in my local template file and then run this script, it succeeds and I see that my local files aren't being used in the expanded yaml. Is this scenario not supported?
from azure-pipelines-yaml.
Another thing which can be done is to make it like Gitlab - you can create an online validation tool (which is basically just a textarea) in the Azure Pipelines web app. The user will paste their yaml, and it'll show all the validation errors.
from azure-pipelines-yaml.
/cc @gopinathch
from azure-pipelines-yaml.
@kmahone i know you’d appreciate this!!
from azure-pipelines-yaml.
Is there any progress on providing this tool. The tool should help you validate and test your yaml instead of running your pipelines all the time.
from azure-pipelines-yaml.
Since it has not been mentioned, the VSCode extension does at least some local validation (I get red squiggles upon using invalid keywords or indentation): https://marketplace.visualstudio.com/items?itemName=ms-azure-devops.azure-pipelines
(the extension appears to use ajv, which I tried to run manually, via pajv, but got some errors -- for a pipeline schema which otherwise builds successfully. Probably just a configuration issue. Have not dug further as the extension is working great for me - thanks!)
from azure-pipelines-yaml.
Awesome, thanks!
@vtbassmatt Are there plans to provide a task for this at least?
It's a bit cumbersome to re-implement this for every customer.
from azure-pipelines-yaml.
Thanks!
from azure-pipelines-yaml.
@vtbassmatt noted. What I would recommend is that since yaml supports multiple document syntax with '---', to be able to add a comment or something to indicate which file it would be (by file path), that way the document and all its related sub templates and whatnot could be supplied as one entry to YamlOverride
from azure-pipelines-yaml.
If YAML templates are supported then I'm happy - Will give it a go.
Feel free to write that post, happy to share.
from azure-pipelines-yaml.
Great to hear, thanks!
from azure-pipelines-yaml.
@tomkerkhove I am currently sitting at the code for the PR
@JustinGrote do you have a direct link to the API documentation. It's kinda hard to find for me.
from azure-pipelines-yaml.
@SebastianSchuetze it's part of the preview API docs but I can't find the link anymore, however both of these reference the info:
#34 (comment)
https://docs.microsoft.com/en-us/azure/devops/release-notes/2020/pipelines/sprint-165-update#preview-fully-parsed-yaml-document-without-running-the-pipeline
Also if you look at my source code it's laid out there too.
from azure-pipelines-yaml.
We're working on getting the API docs to accurately reflect this (and other Pipelines endpoints).
from azure-pipelines-yaml.
So I've been testing this out and this seems to only work if your entire pipeline definition is in a single file, and/or you are only trying to validate the pipeline entry point file, which doesn't work for us. We generally use templates, and as soon as you do that, it doesn't seem like it's possible for those to be picked up. If I make a typo in my local template file and then run this script, it succeeds and I see that my local files aren't being used in the expanded yaml. Is this scenario not supported?
@vtbassmatt already commented on this. the short answer is "not yet"
from azure-pipelines-yaml.
@JustinGrote - thanks! I missed that (somehow)
from azure-pipelines-yaml.
Has something changed very recently? I've been trying this API for the first time today, and neither curl nor the PowerShell function provided by @JustinGrote work for me.
- Authorization for this API (not other DevOps APIs) only works if the username part of the HTTP Basic creds is left blank.
- The response is a redirect to a web page. If run through a browser, I end up at https://aex.dev.azure.com/me?mkt=en-US
from azure-pipelines-yaml.
@joergjo that sounds like an authentication or authorization problem; nothing in our API would trigger that behavior. You can call other APIs without a problem, though?
from azure-pipelines-yaml.
what scopes do I need on the PAT for this to work? the bare minimum, obviously. thanks
from azure-pipelines-yaml.
Related Issues (20)
- by design there´s not available option in DeVops Service to create a new pipeline yaml for "existing" branch HOT 5
- deploy built artifacts in container uploads both checked out projects instead of right one HOT 2
- how to triger a build pipeline from powershell HOT 2
- Pipeline resource trigger documentation missing prerequisite HOT 1
- could find the branch error in azure yaml HOT 2
- python task ran successfull but pipeline is faiing with bash exit code 1 HOT 3
- Azure YAML Pipelines - Using template expression variables at non-global scope HOT 1
- Examples for resource pipeline and source inputs are not clear. HOT 9
- Hi Team While running my Azure pipeline.yaml I am getting following error: directive are not supported for the expression that are embedded within the string Directive are only supported when the entire value is an expression HOT 1
- This repo is missing important files
- It is possible to convert a json to variables/parameters YAML and iterate? HOT 3
- Support for conditions in templates? HOT 1
- Custom expression/function in Yaml HOT 1
- Azure DevOps YAML Template Powershell script file issue HOT 2
- Azure Pipelines Resource Trigger (branch filter) not working as expected. HOT 2
- GitHub Actions Build Error: Invalid App Path for Django-Celery-Beat Dockerfile HOT 3
- Error running pipeline after renaming default GitHub branch from 'master' to 'main' HOT 3
- Publishing artifacts from a failed step HOT 1
- Pass variables from Build pipeline to Release HOT 2
- Error signing debug variant bundle android app using YAML file 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 azure-pipelines-yaml.