Skip to content

Conversation

@capsali
Copy link

@capsali capsali commented Feb 1, 2017

No description provided.

@ociuhandu
Copy link
Member

ociuhandu commented Feb 1, 2017

General notes:

  1. function naming: what's the point of naming most functions like "Start-XXX"? I think those have to be renamed to actually show what the functions do.
    2.config/environment/build variables should be stored in a "config.ps1" file. Also, the declared functions in a "library/utils" file. Those get imported and then you have the "logic" in the main file, without all the functions declarations.
  2. instead of "cd $folder" we rely on pushd $folder + popd once the task in that folder is finished. This way we avoid issues with the current location. And we don't use (unless really justified) relative paths. Relative path = $base_path_in_variable + $relative_path

head -1 $WORKSPACE/gitlog.txt | tee $WORKSPACE/lastrancommit.txt
}

function Start-CommitJob {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that this function does is starting a job for checking a commit, so the naming should reflect that, it's not "starting a commit job" - it won't commit anything.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed the functions to reflect what they actually do

done < $WORKSPACE/gitlog.txt
}

export WORKSPACE="/var/lib/jenkins/jobs/master-job/workspace"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You never hardcode a workspace that's inside the jenkins-managed workspaces. If you need a common workspace to be shared by multiple jobs, you use a dedicated folder created for that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a path that was used when testing and forgot to remove it prior to PR

}

function Get-GitLog {
currentcommit=`cat $WORKSPACE/lastrancommit.txt`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use powershell cmd-lets, not aliases that are "linux-like"

while read line
do
echo "Starting job for commitID $line"
curl -X POST "http://$jenk_user:$jenk_api@10.20.1.3:8080/job/ovs-build-job/buildWithParameters?token=b204eee759ab38ebb986d223f6c5b4ce&commitid=$line"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use powershell cmd-lets, not aliases that are "linux-like"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a linux script and is run on jenkins slave

if [ ! -e $lastranfile ]; then
echo "LastRanFile doesn't exist. Creating it."
cd $WORKSPACE/ovs
git rev-parse HEAD | tee $WORKSPACE/lastrancommit.txt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you run a test on that "first commit"?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Now it will run the "first commit" test


if ( $Status -eq "ERROR" ) {
write-host "Sending make error E-mail for $commitID"
Send-PassEmail $from "mgheorghe@cloudbasesolutions.com" $smtpServer $commitLink $logLink
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't "$to" be listed here as well?

@@ -0,0 +1,110 @@
$ErrorActionPreference = "Stop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this script required / executed for each run?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, removed

- shell: |
#!/bin/bash
set -e
function Check-LastRanFile {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these functions defined both here and in scripts/unit-tests/linux/ovs-git.sh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will not be present in the jjb


$Status = $env:status
$commitID = $env:commitid
$basePath = "C:\OpenStack\OpenvSwitch"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, use config.ps1, no static variables defined in main file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,87 @@
function Send-PassEmail ($from, $to, $smtpServer, $commitLink, $logLink) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a function that takes as parameter also the PASS/FAIL/ERROR status? What's the significant difference between them?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combined them into one functions "Send-Email"

…d jjb file since it will be hosted in another repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants