-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
pipeline { | ||
agent none | ||
stages { | ||
stage('Sequential') { | ||
agent { | ||
label 'for-sequential' | ||
} | ||
environment { | ||
FOR_SEQUENTIAL = "some-value" | ||
} | ||
stages { | ||
stage('In Sequential 1') { | ||
steps { | ||
echo "In Sequential 1" | ||
} | ||
} | ||
stage('In Sequential 2') { | ||
steps { | ||
echo "In Sequential 2" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use core_model::url_format::uri_to_path; | ||
use core_model::{url_format, CocoConfig, Settings}; | ||
use ignore::Walk; | ||
use jenkinsfile::Jenkinsfile; | ||
use std::fs; | ||
use std::path::PathBuf; | ||
|
||
pub fn execute(config: CocoConfig) { | ||
for repo in &config.repos { | ||
let url_str = repo.url.as_str(); | ||
let origin_files = lookup_jenkinsfile(url_str); | ||
let mut results = vec![]; | ||
|
||
for path in origin_files { | ||
let contents = fs::read_to_string(path).expect("Something went wrong reading the file"); | ||
if let Some(jenkinsfile) = Jenkinsfile::from_str(contents.as_str()) { | ||
results.push(jenkinsfile); | ||
} | ||
} | ||
|
||
let result = serde_json::to_string_pretty(&results).unwrap(); | ||
write_to_json_file(url_str, &result); | ||
} | ||
} | ||
|
||
fn write_to_json_file(url_str: &str, result: &String) { | ||
let file_name = url_format::json_filename(url_str); | ||
let output_file = Settings::pipeline().join(file_name); | ||
fs::write(output_file, result).expect("cannot write file"); | ||
} | ||
|
||
fn lookup_jenkinsfile(url_str: &str) -> Vec<PathBuf> { | ||
let path = uri_to_path(url_str); | ||
let mut origin_files = vec![]; | ||
for result in Walk::new(path) { | ||
if let Ok(entry) = result { | ||
if !entry.file_type().unwrap().is_file() { | ||
continue; | ||
} | ||
|
||
if entry.file_name().to_str().unwrap() == "Jenkinsfile" { | ||
origin_files.push(entry.into_path()); | ||
} | ||
} | ||
} | ||
|
||
origin_files | ||
} |