Jenkins Job DSL:我想通过提交或标记来获取分支

时间:2016-11-15 03:05:49

标签: jenkins jenkins-job-dsl

关注我的头衔。

我使用groovy来做到这一点。

但它不起作用。谁能问我怎么做?

以下是我的来源:

job("AAA") {
parameters {
  stringParam('branch_name', 'master', 'input branch name')
  stringParam('commit_id', '123456', 'input commit id')
}
gitSCM {
  userRemoteConfigs {
   userRemoteConfig {
    url("ssh://git@abc/abc.git")
    name("${branch_name}")
    }
  }
  branches {
    branchSpec {
      name("${commit_id}")
    }
  }}

感谢。

1 个答案:

答案 0 :(得分:0)

我们这样做:

#include <functional> // std::bind
#include <iostream>
#include <boost/asio.hpp>

const auto noop = std::bind([]{});

int main()
{
  using boost::asio::ip::tcp;
  boost::asio::io_service io_service;

  // Create all I/O objects.
  tcp::acceptor acceptor(io_service, tcp::endpoint(tcp::v4(), 0));
  tcp::socket socket1(io_service);
  tcp::socket socket2(io_service);

  // Connect sockets.
  acceptor.async_accept(socket1, noop);
  socket2.async_connect(acceptor.local_endpoint(), noop);
  io_service.run();
  io_service.reset();

  const std::string delimiter = "\r\n\r\n";

  // Write two commands from socket1 to socket2.
  boost::asio::write(socket1, boost::asio::buffer("cmd1" + delimiter));
  boost::asio::write(socket1, boost::asio::buffer("cmd2" + delimiter));

  // Read a single command from socket2.
  boost::asio::streambuf streambuf;
  boost::asio::async_read_until(socket2, streambuf, delimiter,
    [delimiter, &streambuf](
      const boost::system::error_code& error_code,
      std::size_t bytes_transferred)
    {
      // Verify streambuf contains more data beyond the delimiter. (e.g.
      // async_read_until read beyond the delimiter)
      assert(streambuf.size() > bytes_transferred);

      // Extract up to the first delimiter.
      std::string command{
        buffers_begin(streambuf.data()),
        buffers_begin(streambuf.data()) + bytes_transferred
          - delimiter.size()};

      // Consume through the first delimiter so that subsequent async_read_until
      // will not reiterate over the same data.
      streambuf.consume(bytes_transferred);

      assert(command == "cmd1");
      std::cout << "received command: " << command << "\n"
                << "streambuf contains " << streambuf.size() << " bytes."
                << std::endl;
    }
  );
  io_service.run();
}

但它仅在手动启动时使用。由于它是由gerrit触发的,因此它设置了使用的值。这是你的问题,它被触发,然后没有设置值?