小编Nic*_*ith的帖子

Groovy .each只迭代一次

该脚本不会遍历'modules'数组的所有值.

class Module {
    public String name = '';
    public Boolean isCustom = false;
    public Module(String name, Boolean custom){
        this.name = name;
        this.isCustom = custom;
    }
}

//creates array from the ext_module env var
modules = [];
EXT_MODULE.split(',').each { 
    modules.add(new Module(it, false));
}


println modules;
modules.each {  
    println "MODULE NAME ::::: ${it.name}"
    if(it.isCustom)
    {
        println "install custom";
    } else {
        println "install non custom";
    }
};
Run Code Online (Sandbox Code Playgroud)

这是运行的结果.该数组显示4个元素,但.each黑色内的代码只执行一次.

运行:打印消息[Module @ 71f09325,Module @ e1ddb41,Module @ 7069a674,Module @ 1f68f952]
运行:打印消息MODULE NAME ::::: puppetlabs-ntp …

groovy jenkins jenkins-pipeline

13
推荐指数
1
解决办法
6390
查看次数

openpyxl创建一个引用另一个工作表中的单元格的函数

我几天前刚刚开始使用openpyxl,它是一个很棒的库.但是,对于高级功能,文档似乎很少.我有几个问题.

  1. openpyxl似乎改变了我插入到小写的公式,导致excel的未知引用.
  2. 此外,我更改了工作表的名称以适应小写,仍然找到#NAME?参考所在的单元格中的错误.

有人可以告诉我如何或在哪里找到如何从openpyxl中的另一张纸中引用单元格

import openpyxl.Workbook
wb = Workbook()
ws = wb.get_active_sheet()
#shows up lowercase with name error in excel
ws.cell('A1).value = "$'Sheet'.E7 + 123"
#still shows a name error in excel
ws.cell('A2').value = "$'sheet'.E7 + 123"
Run Code Online (Sandbox Code Playgroud)

python openpyxl

9
推荐指数
1
解决办法
4470
查看次数

S#SSH .Net库中的Sudo命令

这是我能找到的SSH .Net库最简单的sudo实现.但是,我无法让它发挥作用.

    using (var ssh = new SshClient("hostname", "username", "password"))
        {
            ssh.Connect();
            var input = new MemoryStream();
            var sr = new StreamWriter(input);
            var output = Console.OpenStandardOutput();

            var shell = ssh.CreateShell(input, output, output);
            shell.Stopped += delegate
            {
                Console.WriteLine("\nDisconnected...");
            };

            shell.Start();
            sr.WriteLine("sudo ls");
            sr.Flush();
            Thread.Sleep(1000 * 1);
            sr.WriteLine("password");
            sr.Flush();
            Thread.Sleep(1000 * 100);
            shell.Stop();
        }
Run Code Online (Sandbox Code Playgroud)

我每次都会收到以下错误

上次登录时间:2015年1月14日星期三15:51:46来自mycomputer


公司的东西


SshNet.Logging详细:1:来自服务器的ReceiveMessage:'ChannelDataMessage':'SSH_MSG_CHANNEL_DATA:#0'.SshNet.Logging详细:1:来自服务器的ReceiveMessage:'ChannelDataMessage':'SSH_MSG_CHANNEL_DATA:#0'.[1; 36m这是BASH [1; 31m4.1 [1; 36m-显示在[1; 31m:0.0 [m]

1月14日星期三15:55:50 CST 2015 SshNet.Logging详细:1:来自服务器的ReceiveMessage:'ChannelDataMessage':'SSH_MSG_CHANNEL_DATA:#0'.SshNet.Logging详细:1:来自服务器的ReceiveMessage:'ChannelDataMessage':'SSH_MSG_CHANNEL_DATA:#0'. -bash:而且,:找不到命令 [0; 34musername @ host [0; 31m [15:55:50]> [0m

.net c# ssh

4
推荐指数
1
解决办法
1万
查看次数

使用Jenkins Groovy脚本创建Unix Slave

我想知道如何使用Jenkins Groovy脚本创建一个unix slave并启动slave.我有以下代码,它工作得很好.但是,它不会在从属设备中创建ssh选项,也不会启动从属设备.我看到了JNLPLauncher(),我认为我需要将它改成某种ssh启动器.即使它指向我似乎无法找到的文档,我将不胜感激任何帮助.此外,此代码用于在构建时启动从属,并在构建结束后删除从属.我需要根据用户选择的参数进行动态从属分配.因此,对于如何实现这一点的任何其他想法表示赞赏.

import jenkins.model.*
import hudson.model.*
import hudson.slaves.*

Jenkins.instance.addNode(
  new DumbSlave(
    "test-script",
    "test slave description",
    "/export/home/pe-deploy/",
    "1",
    Node.Mode.NORMAL,
    "test-slave-label",
    new JNLPLauncher(),
    new RetentionStrategy.Always(),
    new LinkedList()))
Run Code Online (Sandbox Code Playgroud)

groovy jenkins jenkins-job-dsl

3
推荐指数
1
解决办法
5355
查看次数

标签 统计

groovy ×2

jenkins ×2

.net ×1

c# ×1

jenkins-job-dsl ×1

jenkins-pipeline ×1

openpyxl ×1

python ×1

ssh ×1