Skip to content

Commit

Permalink
fix: fix jenkinsfile in error pos issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Feb 26, 2021
1 parent 0995ee6 commit 3f95dd4
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 76 deletions.
52 changes: 3 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion plugins/coco_container/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ edition = "2018"

[dependencies]
dockerfile-parser = "0.7.1"
jenkinsfile = "0.1.1"

[dependencies.core_model]
path = "../../core_model"
Expand Down
24 changes: 0 additions & 24 deletions plugins/coco_container/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ pub fn plugin() -> Box<dyn PluginInterface> {
#[cfg(test)]
mod tests {
use dockerfile_parser::Dockerfile;
use jenkinsfile::Jenkinsfile;

#[test]
pub fn demo() {
Expand All @@ -53,27 +52,4 @@ mod tests {
}
}
}

#[test]
pub fn should_parse_hello_world() {
let code = r#"pipeline {
agent { docker 'maven:3.3.3' }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
}
"#;
let jenkinsfile = Jenkinsfile::from_str(code).unwrap();

for stage in jenkinsfile.stages {
println!("stage # {}", stage.name);
for ins in stage.steps {
println!("steps # {}", ins);
}
}
}
}
3 changes: 1 addition & 2 deletions plugins/coco_pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
# Jenkins Declarative Parser
jdp = "0.2.2"
jenkinsfile = "0.1.1"

# grammar generator
pest = "2.1.3"
Expand Down
28 changes: 28 additions & 0 deletions plugins/coco_pipeline/src/jenkinsfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,31 @@ pub struct PostConfig {
pub key: String,
pub value: Vec<JenkinsJob>,
}

#[cfg(test)]
mod tests {
use jenkinsfile::Jenkinsfile;

#[test]
pub fn should_parse_hello_world() {
let code = r#"pipeline {
agent { docker 'maven:3.3.3' }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
}
"#;
let jenkinsfile = Jenkinsfile::from_str(code).unwrap();

for stage in jenkinsfile.stages {
println!("stage # {}", stage.name);
for ins in stage.steps {
println!("steps # {}", ins);
}
}
}
}

0 comments on commit 3f95dd4

Please sign in to comment.