我想在jenkins中使用git中的git管道脚本
#!groovy
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building..'
}
}
stage('Test') {
steps {
echo 'Testing..'
}
}
stage('Deploy') {
steps {
echo 'Deploying....'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我设置了Repository URL,在"Additional Behaviors"下添加了"Check out to a sub directory"并在那里写了我的子目录.
在"Script-Path"中我写道:mysubdirectory/Jenkinsfile
当我尝试运行它时,我得到以下错误:
java.io.FileNotFoundException
at jenkins.plugins.git.GitSCMFile$3.invoke(GitSCMFile.java:167)
at jenkins.plugins.git.GitSCMFile$3.invoke(GitSCMFile.java:159)
at jenkins.plugins.git.GitSCMFileSystem$3.invoke(GitSCMFileSystem.java:162)
at org.jenkinsci.plugins.gitclient.AbstractGitAPIImpl.withRepository(AbstractGitAPIImpl.java:29)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.withRepository(CliGitAPIImpl.java:71)
at jenkins.plugins.git.GitSCMFileSystem.invoke(GitSCMFileSystem.java:158)
at jenkins.plugins.git.GitSCMFile.content(GitSCMFile.java:159)
at jenkins.scm.api.SCMFile.contentAsString(SCMFile.java:338)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:101)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:59)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:262)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:415)
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
如何从git正确运行Jenkins脚本?
所以我有一堆正则表达式,我尝试使用以下If语句查看它们是否与另一个字符串匹配:
if(samplestring.match(regex1)){
console.log("regex1");
} else if(samplestring.match(regex2)){
console.log("regex2");
} else if(samplestring.match(regex3)){
console.log("regex3");
}
Run Code Online (Sandbox Code Playgroud)
但是,一旦我需要使用更多的正则表达式,这就会变得很丑陋,所以我想使用如下的switch case语句:
switch(samplestring){
case samplestring.match(regex1): console.log("regex1");
case samplestring.match(regex2): console.log("regex2");
case samplestring.match(regex3): console.log("regex3");
}
Run Code Online (Sandbox Code Playgroud)
问题是它不能像我在上面的示例中那样工作。关于它如何工作的任何想法?
我在 Angular 中的依赖项出现问题,所以我在我的项目中重新安装了它。所以,我所做的是:
npm uninstall -g angular-cli
npm cache clean or npm cache verify
npm install -g @angular/cli@latest
rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install
Run Code Online (Sandbox Code Playgroud)
但是现在,当尝试使用 npm start 或 ngserve 时,会发生这种情况
The serve command requires to be run in an Angular project, but a project definition could not be found.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! angular@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed …Run Code Online (Sandbox Code Playgroud) 我尝试在Angular项目中使用csv文件,如下所示:
import * as data1 from "./data.csv";
import * as data2 from "./data2.csv";
Run Code Online (Sandbox Code Playgroud)
它们位于与我要使用它们的.ts相同的文件夹中。我收到以下错误:
找不到模块“ data.csv”
我还尝试将它们移动到资产文件夹:
import * as data1 from '/assets/data.csv';
Run Code Online (Sandbox Code Playgroud)
但是错误仍然显示出来。我究竟做错了什么?