Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement a PowerShell example #43

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Please see the [CONTRIBUTING guide](../CONTRIBUTING.md) for additional informati

| Environment Template | Concepts Demonstrated |
| ------ | --------------------- |
| [powershell-script](./v2023-09/environment_templates/powershell-script.yaml) | environment, calling embedded file with PowerShell |
| [python-venv](./v2023-09/environment_templates/python-venv.yaml) | environment, openjd_env, embedded file |

## License
Expand Down
50 changes: 50 additions & 0 deletions samples/v2023-09/environment_templates/powershell-script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# ----
# Demonstrates
# ----
# Using an Environment Template to call powershell scripts on Windows
# Notably this adds the `filename: script.ps1` setting and shows how
# to call Powershell correctly.
#
# ----
# Requirements
# ----
# - powershell
#
# -----
# Contributors to this template:
# Alex Hughes (https://github.com/Ahuge)

specificationVersion: environment-2023-09
environment:
name: PowershellScript
description: >
Executes a simple powershell script showing correctly how to call it without errors.
script:
actions:
onEnter:
# Need to specify the `-File <script>` args for Powershell instead of just passing the `<script>
command: powershell
args:
- "-File"
- "{{Env.File.Enter}}"
onExit:
command: powershell
args:
- "-File"
- "{{Env.File.Exit}}"
embeddedFiles:
- name: Enter
type: TEXT
# Required to name our powershell script a name that ends with ".ps1"
# See: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.4#long-description
filename: enter.ps1
data: |
Write-Output "Powershell Enter"
echo "openjd_env: ENVIRONMENT_VARIABLE=ENVIRONMENT_VALUE"
- name: Exit
type: TEXT
filename: exit.ps1
data: |
Write-Output "Powershell Exit"