azuredevops-buildagents icon indicating copy to clipboard operation
azuredevops-buildagents copied to clipboard

Templated the yml file in a way it's usable and can be referred elsewhere

Open ddprince-pro opened this issue 2 years ago • 10 comments

Changed the source branch, so that we can continue to do modifications on main on our side. Please see PR #16 for full conversation.

Thank you!

ddprince-pro avatar Apr 26 '22 00:04 ddprince-pro

Thank you for this! I'm currently testing my pipeline.

Already some questions:

  • I don't have time/knowledge to replicate your setup. Could you please test your pipeline with keeping the "trigger: none" in my file? It needs to be in there for my use case, I hope it can stay in there for yours. Could you please check?
  • Would you mind writing an update to the README.md, explaining how to implement your use case? I'd love to try, but I am unsure how your setup looks: different repo or same? GitHub or DevOps? Do you have a sample/easy starter pipeline for such a setup?
  • Also, could you explain these three parameters in the Readme? image

YannickRe avatar Apr 26 '22 20:04 YannickRe

@ddprince-yaksa I have created my VM's without issues, using your code! So if you could take a look into my questions above, I am more than willing to merge this PR soon 😊

YannickRe avatar Apr 27 '22 11:04 YannickRe

Hi @YannickRe it will be a pleasure to write down a README.md file for the sake of understanding every proposed changes. We are using these templates directly within Azure DevOps and there's a GitHub service connection having access to clone this repository so that we can use these templates here for the rest of the pipeline. Since we're doing this, we need to specify the path where the build agent can find the scripts within this repository and not ours.

Also, we can't have the instruction "trigger" in a template file, this is an Azure DevOps YML template file restriction. The trigger instruction can only be used within the "master" YML file, the one which is being used to define your pipeline in a whole (which is also sometimes referring other templates as well along the way). There is indeed something I could do to remediate this restriction, but will require me a little more tweaking. Basically, I would revert the change being made directly inside your file and I would create another file containing a "templated" version of the rest of the steps. The "main" file would then contain the trigger and a reference to the new template.

I'll keep you posted once I've setup the README.md file.

ddprince-pro avatar Apr 27 '22 12:04 ddprince-pro

@ddprince-yaksa Good, that templatizing inside this repo sounds like a workable thing. This will allow for both mine and your scenario, and allow us more easily to assure that both our usages keep working with future changes.

Thank you for the explanation, it sounds super useful and I am honored that you are using this in production AND willing to contribute back. Looking forward to the README!

YannickRe avatar Apr 27 '22 15:04 YannickRe

Hey @YannickRe sorry I haven't been able to give an update for a long time, I've switched from doing this kind of automation to other projects internally. I'm planning to document the build agent automation, so I'll also pass on this pull request and wrap it up!

ddprince-pro avatar Jun 15 '22 12:06 ddprince-pro

@YannickRe I updated the README.md file. Please check and let me know if it misses information! :) I've documented assuming that I'll provide to you another Pull Request with our modifications on the cleanup image YML file. If you wish, I could also merge these changes within this Pull Request. I think it would make more sense. Let me know what are your thoughts regarding that! :)

ddprince-pro avatar Jun 15 '22 13:06 ddprince-pro

@YannickRe I think I will do another modification. I feel like the parameters repository_base_path and resource_repo_name are way too much redundant. I think it will be better and clearer if only one needs to be provided. I'll do some testing on my side and provide the modifications.

ddprince-pro avatar Jun 15 '22 13:06 ddprince-pro

@ddprince-yaksa thank you for these adjustments! I think we are almost there:

  • I'd like buildagent-generation.yml to have the trigger statement
  • A new file with the templatized version of the steps.

THis will essentially allow backwards compatibility for existing users of this yml file and give you the opportunity to reference the templatized version in your own project. If you are willing to make this change, you can just do it in this PR still.

YannickRe avatar Jun 23 '22 21:06 YannickRe

@YannickRe yes sure, I'll make the modifications with pleasure. I'll keep you posted once it's done!

ddprince-pro avatar Jun 24 '22 00:06 ddprince-pro

Hey @YannickRe I think I've wrapped up everything. Though, please make sure to test it on your side just to make sure.

Please let me know if there is anything else!

Thanks!

ddprince-pro avatar Aug 11 '22 21:08 ddprince-pro

@ddprince-yaksa it took me a while (I'm sorry for that!) but I finally was able to verify both use cases for this repository now. thank you for the README too! I made some final tweaks in naming the files and in your example use case, but those were some minor things. I really love the implementation, and thank you for seeing it through to the end!

YannickRe avatar Oct 01 '22 13:10 YannickRe