Using Git to Back Up and Version Control testgrinder Projects
testgrinder service will be discontinued on January 31, 2025
testgrinder allows you to link a project to an external git repository. Once the link is established, you can:
Compare the project to the latest commit in the specified repository branch
Export the project to the repository as a new commit in the branch you specified
Revert the project to the latest commit in the repository branch.
As an example, here's the result of comparing a project to the repository:
In order for testgrinder to communicate with the git repository, the repository needs to be accessible via the Internet. It may either be a git repository on the server you control or a repository on a hosting provider, such as github.com or bitbucket.org.
Let's take a testgrinder project and go through the steps of linking it to a github.com repository, for example, and explore what we can do once the link is established.
The main steps are:
Create a github.com repository for the testgrinder project
Create an SSH identity in testgrinder (or reuse one created previously)
Add the SSH identity's public key to your github.com account to grant testgrinder access to the repository
Configure the testgrinder project link to the git repository
Create a github.com repository
Sign in to github.com and create a new repository. Give it any name you like. Here I used tg-project-link-demo:
You may choose either a Public or Private repository - testgrinder can work with both. Keep in mind that a public repository will be visible to anyone on the internet.
At the very least, it is recommended to add a README file to the repository at this time, as this will create the default branch (main) in the repository. Otherwise, you'll need to add a branch yourself as testgrinder expects the branch to exist.
Click Create repository and github will create the repository with the automatically created README file:
When we get to configuring the testgrinder project link to the repository, we will need the repository URL. You can see it by clicking the Code button:
Authorize testgrinder access to the repository
You grant testgrinder access to the repository by first creating an SSH key identity in your testgrinder account and then granting access to the same SSH key in your github repository.
Let's create the SSH key identity in testgrinder first. Sign in to your testgrinder account, click on your name in the top right corner, navigate to the Account page, then select the Identities tab, and click the Add SSH key identity button. Give the identity a name, e.g., github:
Click Add and you'll see the identity appear in the list:
Click View to see the identity's SSH Public Key:
Soon you'll need to copy the Public Key and paste it into github to authorize access from testgrinder.
When creating an identity, testgrinder also creates a Private Key matching the Public Key. The Private Key is stored securely by testgrinder and is never displayed.
Copy the content of the Public Key field to the clipboard and switch to the github.com repository page. Once there, select the repository's Settings tab and select Deploy keys on the left. You should see a page like this:
Click the Add deploy key button. Give it any title you'd like (e.g., testgrinder) and paste the Public Key copied from testgrinder into the Key field. Check off Allow write access to enable testgrinder to export to the repository:
Click the Add key button:
Link a testgrinder project to the repository
For this demo I'll use a simple project with one script in it:
To link the project to the repository, click on the project's root folder and choose the External Repository tab:
Click the Configure button (the button will be available to anyone with [at least] Edit access). Once the configuration editor opens, choose Git and fill in the repository URL, Branch, and choose the identity you created earlier:
Click Save. You should see this page indicating that the link has been configured:
We can test the connection by running the Compare action.
Congratulations! You've established a link between your testgrinder project and a repository in github.
If you run into a problem, please review the previous steps to see if anything was missed. Get in touch with us if you need further assistance.
Compare a Project to the Repository
Click the Compare button. After a few seconds, you should see that testgrinder detected some differences. The Compare action is available to anyone with (at least) View access to the project:
Export Project to Git
When you click the Export button, testgrinder will export the current state of the project as a new commit in the repository branch. The user will need to have Edit access to the project to see the Export button.
Click the Export button. After a few seconds, testgrinder will indicate that the export was a success:
Clicking Compare confirms that the project and the repository now match:
Let's switch to github.com and see the commit that testgrinder has created:
Note that testgrinder puts scripts under the scripts folder. If you have files attached to the project they will appear under the files folder. This allows you to keep other files in the repository without them conflicting with the files testgrinder commits. testgrinder will ignore any file outside of both the scripts folder and files folder. For example, the README file you added earlier when creating the project will still be there.
Note that in the past, when testgrinder referred to scripts as features, and the scripts folder was named features. testgrinder remembers it and acts accordingly when you work with an older repository. Comparing to such an older repository will show that the script files have been renamed. And exporting your project to it will move the scripts to scripts folder and give them the .script extension.
Reverting Project Changes
Let's say you've made changes to the project that you would like to revert to match the latest repository commit. Here I have changed the project by adding a new script and modifying the existing one (as displayed by running Compare):
To undo these changes, click the Revert button, confirm the action, and the changes will be reverted:
Running the Compare action confirms that the revert was successful.
Project Version Control
Every time you export the project, testgrinder creates a new commit in the repository branch. This enables you to export the project at key points of its lifetime and thus maintain a history of changes in the repository.
If you ever need to revert to an earlier commit, simply create a new branch off of the commit, configure the repository link with this branch in testgrinder, and run the Revert action.
Editing Scripts Outside of testgrinder
If you'd like to edit scripts outside of testgrinder (to make mass edits, for example), you may find it useful to export the project to the repository, make the edits, commit the edits, and then revert the testgrinder projects to reflect the changes in the testgrinder project.
Conclusion
We hope you find the integration of testgrinder with external git repositories useful. Let us know what you think or if we can make this more useful to you.
Last updated