TaskGIT
class tasks.task_git.TaskGIT
Run git commands on a repository.
Note that the git task allows you to interact with your git repository, but does not automatically synchronise the flow scripts in your git repository with your Cloudomation account. To synchronise flow scripts and settings from git into your Cloudomation account, use this git sync flow script available in the public flow script library. Feel free to make a copy and adapt it to your specific use case.
Two commands are available:
- get
- metadata
get: fetch the specified reference and return the files. The files can either be returned in the outputs of the task or placed in cloudomation using the "files_path" argument.
metadata: Only get the metadata of the specified reference.
Inputs
Name | Type | Default | Description |
---|---|---|---|
command | str | The command you want to execute. Supports "get" and "metadata" | |
files_path | str | None | Save the files of the repository in cloudomation, this is the target directory. In the case of a get command, the contents of the remote repository will be stored here. If not specified or None the output files will exist. |
httpCookie | str | None | Authentication for some private git repositories is possible via http cookie |
password | str | None | The password to be used for authentication. Can be None. Alternatively, SSH keys can be used. |
ref | str | develop | A commit reference, e.g. the commit you want to get. Can be a branch, tag, or git commit SHA |
repository_url | str | The remote URL of the repository. The url can contain HTTP basic auth credentials | |
ssh_hostkey | str | None | The content of the ssh known hosts file. Can be False to disable host key checking |
ssh_key | str | None | The content of the ssh private keyfile associated with the repository, currently only works with non-password protected keyfiles |
username | str | None | The username to be used for authentication. Can be None. Alternatively, SSH keys can be used. |
Outputs
Name | Type | Default | Description |
---|---|---|---|
author_email | str | The email of the commiter of the specified reference | |
author_name | str | The name of the commiter of the specified reference | |
commit_message | str | The commit message of the reference | |
commit_sha | str | The sha of the commit | |
date | float | The date and time of the commit as POSIX timestamp | |
date_str | str | The date and time in iso8601 date and time, with zone info | |
error | str | The stderr of the last successful git command | |
files | list | A list of dictionaries with two keys: name and content | |
log | list | ||
output | str | The stdout of the last successful git command | |
short_sha | str | The short sha of the commit | |
status_code | int | The status code returned by the git command | |
execution_id | int | The ID of the task execution | |
message | str | The ended message for the task. If the task ended with an error, the message will contain information about what went wrong | |
status | str | The ended status for the task. Either "success" or "error". |
Constants
input_list = ['command', 'files_path', 'httpCookie', 'password', 'ref', 'repository_url', 'ssh_hostkey', 'ssh_key', 'username']output_list = ['author_email', 'author_name', 'commit_message', 'commit_sha', 'date', 'date_str', 'error', 'files', 'log', 'output', 'short_sha', 'status_code']version = 1Methods
run ()
Example
import flow_apidef handler(system: flow_api.System, this: flow_api.Execution):task = this.task('GIT',command='get',# The url to a public repositoryrepository_url='https://github.com/starflows/library/',# Get the reference develop, I could also specify a sha, another branch or a tagref='develop',)outputs = task.get('output_value')# Note that both the name and content of every file is part of the outputthis.log(outputs)task2 = this.task('GIT',command='get',repository_url='https://github.com/starflows/library/',files_path='flow_library',ref='v2',)outputs = task2.get('output_value')# Here there are no files in the outputthis.log(outputs)# But they are saved to cloudomation:files = system.files(dir='flow_library')for file in files:this.log(file)return this.success('all done')