Setting up Bamboo SVN commit build trigger - visualsvn-server

Bamboo CI has a build in feature of having the subversion program trigger a build in bamboo when someone commits to the repository. I followed the instructions of what to put in the post commit hook but I am not sure what the 2 arguments are supposed to be for the postcommitbuildtrigger.sh file. Lets say the project name is TEST and the build name is TESTBUILD and the server url is http://localhost:8085. I wrote this in the post commit hook command line.
/<pathtopostcommit.sh> TEST TESTBUILD
Question
The post commit .sh file is on a windows machine. It could be because windows doesnt run .sh files but if thats so does anyone know how to set up this trigger on windows?
Also, I think this will trigger a build immediatly? Is is possible to trigger bamboo to run a poll instead so the build will obey the quiet period?

Have to write your own scripts. Bamboo only distributes mac and linux scripts.

Ok I wrote my own. It's so much nicer than subversion poll time-outs. Tested on:
VisualSvn Server 2.7.2;
Windows Web Server 2008 R2.
PowerShell 2.0
BambooWebApiTrigger.bat
A batch file runner for PowerShell in C:\SvnHooks\:
#echo OFF
rem this file just makes spawning powershell from VisualSvn a tad easier...
rem
rem Args from VisualSvn Server are ignored. Pass Bamboo BUILD KEY as the first
rem parameter to this script.
Powershell.exe -executionpolicy remotesigned -File C:\SvnHooks\BambooWebApiTrigger.ps1 -key %1
BambooWebApiTrigger.ps1
A PowerShell script to run System.Net.WebClient, also in C:\SvnHooks\. Overwrite bamboo.yourdefaultdomain.com with your local Bamboo server:
# A Powershell script to trigger Bamboo to build a specific key
param (
[string]$baseurl = "http://bamboo.radicalsystems.com.au:8085",
[Parameter(Mandatory=$true)]
[string]$key,
[string]$tmp = $null
)
$fullUrl = $baseurl + "/updateAndBuild.action?buildKey=" + $key
if (!$tmp) {
$tmp = [io.path]::GetTempFileName()
}
echo "Pinging Bamboo API at '$fullUrl'"
$client = new-object System.Net.WebClient
$client.DownloadFile($fullUrl, $tmp)
# comment Remove-Item to see the results. It is a HTML result with success message.
# echo "Results are in $tmp"
Remove-Item $tmp
Configure VisualSvn
Right click on project in VisualSvn Server Manager > Properties > Hooks > Post-commit hook (Edit).
Enter this line after any others:
C:\SvnHooks\BambooWebApiTrigger.bat BambooProjectKey
where BambooProjectKey is the key, found after your bamboo url when browsing the Build Plan (not the project). It usually has a hyphen in it: http://bamboo.yourdomain.com:8085/browse/FOO-BAR. In this case, FOO-BAR would be the key.
Configure Bamboo
Change your Bamboo trigger to Repository triggers the build when changes are committed
Options
You can overwrite the key from the VisualSvn post-commit hook dialog, as well as Bamboo base URL and temp file location from the batch file runner.

Related

Vercel dynamic build command based on stage

I have an Expo app where the web component is hosted through Vercel. I use the Vercel GitHub integration for automatic deployment. Expo has a different build command for staging builds and production builds, and it doesn't appear Vercel supports environment/staging based build commands. I'm wondering if I'm possibly missing something and this is possible or anyone has another way of handling this?
I was in a similar situation and managed to solve it with a shell script.
Here is an example you can try out:
#!/bin/bash
if [[ $VERCEL_ENV == "production" ]] ;
then
echo "Building production"
yarn build:production
else
echo "Building staging"
yarn build:staging
fi
And lets say you called the file vercel.sh, you would configure vercel buildCommand to be sh vercel.sh.
Basically, from the shell script you'll be able to use any of the system environment variables vercel provides.

URL Rewrite 2.0 installation fails on Docker

I'm trying to get URL Rewrite 2.0 installed using this Dockerfile:
FROM microsoft/aspnet:4.6.2
WORKDIR /inetpub/wwwroot
COPY obj/Docker/publish .
ADD https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi /install/rewrite_amd64.msi
RUN net start MSIServer
RUN msiexec.exe /i c:\install\rewrite_amd64.msi /quiet /passive /qn /L*v "C:\package.log"
When I build the container image, I see this error message:
The Windows Installer Service could not be accessed. This can occur if the Windows Installer is not correctly installed. Contact your support personnel for assistance.
Looking at package.log after running the container, I see this:
SI (c) (30:A4) [08:32:10:438]: Failed to connect to server. Error: 0x80040150
SI (c) (30:A4) [08:32:10:438]: Note: 1: 2774 2: 0x80040150: 2774 2: 0x80040150
Executing net start msiserver on the running container returns a message that the service is already started, and Google says 0x80040150 could be a problem reading the registry.
Is it expected that installing URL Rewrite this way should work, or do I need to elevate permissions somehow?
Update: Running the same msiexec command on the running container successfully installs URL Rewrite.
I finally figured it out thanks to this article. Using PowerShell to run msiexec with the appropriate switches works. Oddly, it threw "Unable to connect to the remote server" when trying to also download the MSI using PowerShell, so I resorted to using ADD.
Here's the relevant portion of my Dockerfile:
WORKDIR /install
ADD https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi rewrite_amd64.msi
RUN Write-Host 'Installing URL Rewrite' ; \
Start-Process msiexec.exe -ArgumentList '/i', 'rewrite_amd64.msi', '/quiet', '/norestart' -NoNewWindow -Wait

Installing Google Cloud SDK, what is the path to the rc file?

https://cloud.google.com/sdk/docs/quickstart-mac-os-x
I downloaded the tar, and ran the install.sh
Next I got this message, however I don't see any rc / .rc file?
To update your SDK installation to the latest version [162.0.1], run:
$ gcloud components update
Modify profile to update your $PATH and enable shell command
completion?
Do you want to continue (Y/n)? y
The Google Cloud SDK installer will now prompt you to update an rc
file to bring the Google Cloud CLIs into your environment.
Enter a path to an rc file to update, or leave blank to use
[/Users/leongaban/.zshrc]:
Leon, the Cloud SDK installer provides you an option to update your $PATH as well as install shell completion for commands in the Cloud SDK. This is done by adding few lines to your shell startup script (commonly known as a rc file).
Since you selected y to go forward with this step, the installer asks for the location of the rc file (i.e. shell startup script).
It has detected that you use zsh and hence it gives you the default option to update this file /Users/leongaban/.zshrc.
If instead you are using bash you would have to specify something like /Users/leongaban/.bashrc
You could also select n in the previous step and update $PATH and/or shell completion manually too.

stash Pull Request Builder Plugin

Has any one used stash builder plugin.Its documentation says that it adds some environment variables in to the build environment but if i echo them,they all are empty
echo "${sourceBranch}"
echo "${targetBranch}"
echo "${sourceRepositoryOwner}"
echo "${sourceRepositoryName}"
echo "${pullRequestId}"
echo "${destinationRepositoryOwner}"
echo "${destinationReposotryName}"
echo "${pullRequestTitle}"
echo "${sourceCommitHash}"
This plugin is doing nothing for me.Here is my configuration
I am selecting git as SCM [poll scm is not selected]
RepositoryUrl:ssh://git#stash-eng.abc.com:7999/mytool/my_tools_demo.git
Refspec:\+refs/pull-requests/*:refs/remotes/origin/pr/*
Branch Specifier:-origin/pr/${pullRequestId}/from
Then i mark the checkbox "Stash Pull Requests Builder"
and below is the value for diff fields
Cron:H/2 * * * *
Stash Host:stash-eng.abc.com
Stash Credentials:..........
Project:mytool
Repository Name:my_tools_demo
Still its doing nothing.Nor i ma seeing any thing related to plugin in logs.
I'm using this plugin in my company and it's working well.
In my Stash environment, all the project names are in uppercase.
If you have the same kind of project name, can you try to use them in uppercase? (in the Stash Pull Requests Builder section)
If you have one open pull request, can you try to add this comment to trigger a new Jenkins build?
test this please
This is a magic comment to trigger a new PR build from Stash.
I have got the same issue with Jenkins 2.7
According to below issue tracking in Github
https://github.com/nemccarthy/stash-pullrequest-builder-plugin/issues/84
it is fixed in one of the branch
https://github.com/eirikwang/stash-pullrequest-builder-plugin/tree/newChange
And will be merged into master soon..

Building project from cron task

When I build project from terminal by using 'xcodebuild' command I succeed, but when I try to do run same script from cron task I receive error
"Code Sign error: The identity '****' doesn't match any valid certificate/private key pair in the default keychain"
I think problem is in settings and permissions of crontab utility, it seems crontab does not see my keychain
Can anyone provide me terminal command how to make my keychain visible for crontab
I encountered a similar issue with trying to build nightly via cron. The only resolution I found was to create a plist in /Library/LaunchDaemons/ and load it via launchctl. The key necessary is "SessionCreate" otherwise you will quickly run in to problems similar to what was encountered with trying to use cron -- namely that your user login.keychain is not available to the process. "SessionCreate" is similar to "su -l" in that (as far as I understand) it simulates a login and thus default keychains you expect will be available; otherwise, you are stuck with only the System keychain despite the task running as your user.
I found the answers (though not the top answer currently) here useful in troublw shooting this issue: Missing certificates and keys in the keychain while using Jenkins/Hudson as Continuous Integration for iOS and Mac development
You execute your cron job with which account ?
most probably the problem !!
You can add
echo `whoami`
at the beginning of your script to see with which user the script is launched.
Also when a Bash script is launched from cron, it don't use the same environment variable (non login shell) as when you launch it as a user.
When the script launches from cron, it doesn't load your $HOME/.profile (or .bash_profile). Anything you run from cron has to be 100% self-sufficient in terms of it's environment. I'd suggest you make yourself a file called something like "set_build_env.sh" It should contain everything from your .profile that you need to build, such as $PATH, $HOME, $CLASSPATH etc. Then in your build script, load set_build_env.sh using the dot notation or source cmd as ericc said. You should also remove the build-specific lines from your.profile and then source set_build_env from there too so only one place to maintain. Example:
source /home/dmitry/set_build_env.sh #absolute path
. /home/dmitry/set_build_env.sh #dot-space notation same as "source"