Skip to content

Commit

Permalink
Updated with new Task
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHinsh committed Oct 12, 2016
0 parents commit 7cb9a14
Show file tree
Hide file tree
Showing 71 changed files with 6,389 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# default behavior to automatically normalize line endings
* text=auto
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
*.vsix
_build/
_packages/
12 changes: 12 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
assembly-versioning-scheme: MajorMinorPatch
mode: ContinuousDeployment
continuous-delivery-fallback-tag: ''
next-version: 0.1.0
branches:
master:
mode: ContinuousDeployment
tag: ''
((?!master).):
tag: 'Preview'
ignore:
sha: []
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2016 naked Agility Limited - Martin Hinshelwood

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Variable (de|re)Hydration Tasks

Visual Studio Team Services Build and Release Management extensions that help you make use of your build variables in your Release workflows.

Learn more about this extension on the wiki!

##Tasks included

- **Variable Dehydration Task** - During your build you can save the variables to a json file stored with your other build assets
- **Variable Rehydration Task** - During your Release you can load the saved variables and gain access to them.

##Steps

After installing the extension, you can add one (or more) of the tasks to a new or existing build definition or release definition

Full documentation is available on [http://vsts-variable-hydration.readthedocs.io](http://vsts-variable-dehydration.readthedocs.io)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Variable (de|re)Hydration Tasks

Visual Studio Team Services Build and Release Management extensions that help you make use of your build variables in your Release workflows.

Get the [Variable (de|re)Hydration Tasks](https://marketplace.visualstudio.com/items?itemName=nkdagility.variablehydration) extensions for VSTS from the Marketplace.

Learn more about this extension on the wiki!

##Tasks included

- **Variable Dehydration Task** - During your build you can save the variables to a json file stored with your other build assets
- **Variable Rehydration Task** - During your Release you can load the saved variables and gain access to them.

##Steps

After installing the extension, you can add one (or more) of the tasks to a new or existing build definition or release definition

Full documentation is available on [http://vsts-variable-hydration.readthedocs.io](http://vsts-variable-dehydration.readthedocs.io)
117 changes: 117 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
var gulp = require('gulp');
var gutil = require('gulp-util');
var debug = require('gulp-debug');
var del = require('del');
var merge = require('merge-stream');
var path = require('path');
var shell = require('shelljs');
var minimist = require('minimist');
var semver = require('semver');
var fs = require('fs');

var _buildRoot = path.join(__dirname, '_build');
var _packagesRoot = path.join(__dirname, '_packages');

gulp.task('default', ['build']);

gulp.task('build', ['clean'], function () {
var extension = gulp.src(['README.md', 'LICENSE.txt', 'images/**/*', '!images/**/*.pdn', 'vss-extension.json'], { base: '.' })
.pipe(debug({title: 'extension:'}))
.pipe(gulp.dest(_buildRoot));
var task = gulp.src('task/**/*', { base: '.' })
.pipe(debug({title: 'task:'}))
.pipe(gulp.dest(_buildRoot));

return merge(extension, task);
});

gulp.task('clean', function() {
return del([_buildRoot]);
});

gulp.task('test', ['build'], function() {
});

gulp.task('package', ['build'], function() {
var args = minimist(process.argv.slice(2), {});
var options = {
version: args.version,
stage: args.stage,
public: args.public,
private: args.private,
taskId: args.taskId
}

if (options.version) {
if (options.version === 'auto') {
var ref = new Date(2000, 1, 1);
var now = new Date();
var major = 0
var minor = Math.floor((now - ref) / 86400000);
var patch = Math.floor(Math.floor(now.getSeconds() + (60 * (now.getMinutes() + (60 * now.getHours())))) * 0.5)
options.version = major + '.' + minor + '.' + patch
}

if (!semver.valid(options.version)) {
throw new gutil.PluginError('package', 'Invalid semver version: ' + options.version);
}
}

switch (options.stage) {
case 'dev':
options.taskId = '0664FF86-F509-4392-A33C-B2D9239B9AE5';
options.public = false;
options.private = false;
break;
}

updateExtensionManifest(options);
updateTaskManifest(options);

shell.exec('tfx extension create --root "' + _buildRoot + '" --output-path "' + _packagesRoot +'"')
});

updateExtensionManifest = function(options) {
var manifestPath = path.join(_buildRoot, 'vss-extension.json')
var manifest = JSON.parse(fs.readFileSync(manifestPath));

if (options.version) {
manifest.version = options.version;
}

if (options.stage) {
manifest.id = manifest.id + '-' + options.stage
manifest.name = manifest.name + ' (' + options.stage + ')'
}

manifest.public = options.public;

fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
}

updateTaskManifest = function(options) {
var manifestPath = path.join(_buildRoot, 'task', 'task.json')
var manifest = JSON.parse(fs.readFileSync(manifestPath));

if (options.version) {
manifest.version.Major = semver.major(options.version);
manifest.version.Minor = semver.minor(options.version);
manifest.version.Patch = semver.patch(options.version);
}

if (options.stage) {
manifest.friendlyName = manifest.friendlyName + ' (' + options.stage

if (options.version) {
manifest.friendlyName = manifest.friendlyName + ' ' + options.version
}

manifest.friendlyName = manifest.friendlyName + ')'
}

if (options.taskId) {
manifest.id = options.taskId
}

fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 4));
}
Binary file added images/extension-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/screenshot-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions mkdocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
site_name: VSTS Variable (de|re)Hydration Tasks
pages:
- Home: index.md
theme: readthedocs
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "nkdAgility.vsts-variable-hydration-task",
"version": "#{GitVersion.Major}#.#{GitVersion.Minor}#.#{GitVersion.Patch}#",
"description": "Build and release tasks for passing build veriables to a release. ",
"author": "Martin Hinshelwood",
"license": "MIT",
"homepage": "https://github.com/nkdAgility/vsts-variable-hydration-tasks#readme",
"bugs": {
"url": "https://github.com/nkdAgility/vsts-variable-hydration-tasks/issues"
},
"keywords": [
"VSTS",
"release",
"build",
"token",
"json",
"variable",
"hydration"
],
"repository": {
"type": "git",
"url": "git+https://github.com/nkdAgility/vsts-variable-hydration-tasks.git"
},
"devDependencies": {
"del": "^2.0.0",
"gulp": "^3.9.1",
"gulp-debug": "^2.1.2",
"gulp-util": "^3.0.0",
"merge-stream": "^1.0.0",
"shelljs": "^0.3.0",
"minimist": "1.1.1",
"semver": "4.3.3"
}
}
Empty file added tests/data/meta-build.json
Empty file.
Empty file added tests/data/meta-gitversion.json
Empty file.
7 changes: 7 additions & 0 deletions tests/debug-variabledehydration-task.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Save-Module -Name VstsTaskSdk -Path ..\processtemplate-task\ps_modules\


#Import-Module ..\variabledehydration-task\ps_modules\VstsTaskSdk


Invoke-VstsTaskScript -ScriptBlock ([scriptblock]::Create('. ..\variabledehydration-task\dehydrate-veriables.ps1')) -Verbose
40 changes: 40 additions & 0 deletions variabledehydration-task/dehydrate-veriables.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[CmdletBinding()]
param(
[string] $prefixes,
[string] $outpath
)
$prefixes = Get-VstsInput -Name prefixes -Require
$outpath = Get-VstsInput -Name outpath -Require

Write-VstsTaskVerbose "prefixes: $prefixes"
Write-VstsTaskVerbose "outpath: $outpath"

$prefixesList = $prefixes -split ","


foreach ($prefix in $prefixesList)
{
Write-Output "Saving meta data for $prefix"
$path = join-path -path $outpath "meta-$($prefix.ToLower()).json"
Write-VstsTaskVerbose "Save Path: $path"
$PrefixSearch = "Env:$prefix*"
Write-VstsTaskVerbose "Search Prefix: $PrefixSearch"
Get-Childitem -Path $PrefixSearch | select Name,Value

Try
{

$result = Get-Childitem -Path $PrefixSearch | select Name,Value | ConvertTo-Json | Out-File $path
Write-Output "created $result"
}
Catch
{
$ErrorMessage = $_.Exception.Message
$FailedItem = $_.Exception.ItemName
Write-VstsTaskError "Did not get a result retunred from the upload, twas not even JSON!"
Write-VstsTaskError $ErrorMessage
Write-VstsTaskError $result
exit 666
}

}
Binary file added variabledehydration-task/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 7cb9a14

Please sign in to comment.