我需要找到一个人的git用户名/电子邮件,这个人正在推动由不同用户提交的不同提交的更改到远程存储库。
push通过gitblit触发Post-Receive挂钩,触发jenkins作业,并使用非用户特定的SSH身份验证。
答案 0 :(得分:2)
詹金斯没有提供一种简单的方法来实现这一目标。我遇到了类似的问题,花了一些时间才找到合适的解决方案。
我最终使用了Git Plugin和git log的环境变量的组合。
Git Plugin提供了两个环境变量:
GIT_COMMIT - 当前的SHA
GIT_PREVIOUS_COMMIT - 上一次构建的提交的SHA branch(分支中第一次构建的当前SHA)
每次你的git Web Hook触发Jenkins工作时都会得到它。
另一方面,git log
提供了使用format
命令选项获取作者姓名和作者电子邮件的方法。
因此,结合这两个选项,您可以在之前提交的触发Jenkins作业的提交之间获取作者姓名和电子邮件: GIT_PREVIOUS_COMMIT 和当前提交: GIT_COMMIT 使用下面的git log
命令:
git log $GIT_PREVIOUS_COMMIT..$GIT_COMMIT --pretty=format:%an/%ae
在Jenkins工作的执行Shell中。请确保您是git项目的根目录。
答案 1 :(得分:0)
我不得不
<div data-ng-repeat="(subspace_name, subspace) in modules">
<h4 style="width: 50%; text-align: center;">Accounting</h4>
<div class="documenter_sidebar" style="width: 50%;">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<li>
<div class="menuWrapper">
<span class="text-modify btn-fake btn btn-xs menuParentBtn documenter_top" style="margin-left:0;width:100%;"> Articles Expenses </span>
</div>
<ul style="padding: 0;" data-ng-repeat="actionName in modulesActions[subspace_name][module]">
<li>
<div class="menuWrapper">
<div class="input-group">
<span class="input-group-addon">
<input class="ng-pristine ng-untouched ng-valid" type="checkbox" ng-model="restrictedActions[subspace_name][module][actionName]">
</span>
<a class="input-group-addon text-modify btn btn-xs menuParentBtn documenter_top" ng-click="restrictedActions[subspace_name][module][actionName] = !restrictedActions[subspace_name][module][actionName]" style="width:100%; margin-left:0; text-align: left;"> Add </a>
</div>
</div>
</li>
</ul>
<ul style="padding: 0;" data-ng-repeat="actionName in modulesActions[subspace_name][module]">
<ul style="padding: 0;" data-ng-repeat="actionName in modulesActions[subspace_name][module]">
<ul style="padding: 0;" data-ng-repeat="actionName in modulesActions[subspace_name][module]">
</li>
</ul>
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
<ul style="padding: 0;" data-ng-repeat="module in subspace">
</div>
</div>
using System;
using System.Collections.Generic;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using NUnit.Framework;
using System.Linq;
namespace ConsoleApplication1
{
class First_test
{
//static variables
static int row = 1;
static int column = 1;
static string OurXpath = "//form[@id='editUserForm']/div/div[2]/ng-include/div[" + row + "]/div/ul[" + column + "]/li/div/span";
//checking element present
private bool IsElementPresent(By by)
{
try
{
driver.FindElement(by);
return true;
}
catch (NoSuchElementException)
{
return false;
}
}
IWebDriver driver;
[SetUp]
public void Initialize()
{
driver = new FirefoxDriver();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
}
[Test]
public void OpenAppTest()
{
driver.Url = "***********";
//Login
driver.FindElement(By.Id("username")).SendKeys("****");
driver.FindElement(By.Name("password")).SendKeys("****");
driver.FindElement(By.Id("login-submit")).Click();
//Navigating to Users menu
driver.FindElement(By.LinkText("Users")).Click();
//Navigate to User with id
driver.FindElement(By.Id("edit-btn-354")).Click();
driver.FindElement(By.LinkText("Modules Privileges")).Click();
List<string> ModuleNames = new List<string>();
//Adding all privileges to list
List<string> elementTexts = new List<string>(driver.FindElements(By.CssSelector("[class*='text-modify btn-fake btn btn-xs menuParentBtn documenter_top']")).Select(iw => iw.Text));
string sample = elementTexts[1];
Console.WriteLine(sample);
//This is the point where I'm unable to access the element I want to. I know that this part is searching for the /li in the /span. I cant figure out how to search in privious child of that /ul
driver.FindElement(By.XPath("//ul[contains(span,'"+sample+"')]/li[1]")).Click();
//This is for check if finding menus is working right.
elementTexts.ForEach(i => Console.WriteLine("{0}\t", i));
}
[TearDown]
public void EndTest()
{
driver.Quit();
}
}
}
myuser现在是一个环境变量,这里以ant脚本为例:
def triggerUrl = jenkinsUrl + "/job/" + jenkinsJob + "/buildWithParameters?token=" + jenkinsToken + "&myuser=" + user.getName()
new URL(triggerUrl).getText()