小编sam*_*sam的帖子

如何安装git lfs

我正在尝试使用命令克隆 git 存储库:

git clonerepo test_simrkaur
Run Code Online (Sandbox Code Playgroud)

但出现此错误:

[simrkaur@bhlinb40 Repos]$ git clonerepo test_simrkaur
Cloning into 'test_simrkaur'...
remote: Counting objects: 2, done
remote: Total 431 (delta 0), reused 431 (delta 0)
Receiving objects: 100% (431/431), 128.85 KiB | 0 bytes/s, done.
Resolving deltas: 100% (74/74), done.
Checking connectivity... done.
git-lfs smudge -- 'testlfs.txt': git-lfs: command not found
error: external filter git-lfs smudge -- %f failed -1
error: external filter git-lfs smudge -- %f failed
fatal: testlfs.txt: smudge filter lfs failed
warning: Clone …
Run Code Online (Sandbox Code Playgroud)

linux git ssh shell

5
推荐指数
2
解决办法
2万
查看次数

从 perl 文件中的文本中提取和存储键值对中的值

我有一个文本文件,其中包含如下信息:

name=A
class=B
RollNo=C
Run Code Online (Sandbox Code Playgroud)

我想提取 perl 脚本中的值

key(name) = value(A)
key(class) = value(B)
key(RollNo) = value(C)
Run Code Online (Sandbox Code Playgroud)

键应该作为具有值的变量导出。每当我们打字

print $name
Run Code Online (Sandbox Code Playgroud)

输出应该是'A'

我试过了:

open my $fh, '<', $file_name
  or die "Could not open sample.txt: $!";
my @lines = <$fh>;

my %hash;
while (<@lines>) {
    chomp;
    my ($key, $value) = split /=/;
    next unless defined $value;
    $hash{$key} = $value;
}
print %hash;
Run Code Online (Sandbox Code Playgroud)

perl hash

5
推荐指数
2
解决办法
257
查看次数

如何将阶段内的步骤移动到 Jenkins 管道中的函数

我有一个这样的 Jenkinsfile

pipeline {
    agent { label 'master' }
    stages {
        stage('1') {
            steps {
                script {
                    sh '''#!/bin/bash
                    source $EXPORT_PATH_SCRIPT
                    cd $SCRIPT_PATH
                    python -m scripts.test.test
                    '''
                }
            }
        }
        stage('2') {
            steps {
                script {
                    sh '''#!/bin/bash
                    source $EXPORT_PATH_SCRIPT
                    cd $SCRIPT_PATH
                    python -m scripts.test.test
                    '''
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如您所见,在两个阶段我都使用相同的脚本并调用相同的文件。我可以将此步骤移动到 Jenkinsfile 中的一个函数并在脚本中调用该函数吗?像这样

def execute script() {
     return {
       sh '''#!/bin/bash
       source $EXPORT_PATH_SCRIPT
       cd $SCRIPT_PATH
       python -m scripts.test.test
       '''  
}
}
Run Code Online (Sandbox Code Playgroud)

jenkins jenkins-pipeline

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

如何在 perl 中将 ascii 编码文件转换为 utf-8 编码?

我想将带有 ascii 编码的文本文件转换为 utf-8 编码。到目前为止,我已经尝试过这个:

open( my $test, ">:encoding(utf-8)", $test_file ) or die("Error: Could not open file!\n");
Run Code Online (Sandbox Code Playgroud)

并运行以下显示文件编码的命令

file $test_file
test_file: ASCII text
Run Code Online (Sandbox Code Playgroud)

如果我在这里遗漏了什么,请告诉我。

shell perl ascii file utf-8

0
推荐指数
1
解决办法
88
查看次数

标签 统计

perl ×2

shell ×2

ascii ×1

file ×1

git ×1

hash ×1

jenkins ×1

jenkins-pipeline ×1

linux ×1

ssh ×1

utf-8 ×1