Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab_shared_files
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
gitlab_shared_files
Commits
26a982a9
Commit
26a982a9
authored
5 months ago
by
Grégoire Kubler
Committed by
Grégoire Kubler
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
fix : added missing section in windows:select_jobs to handle case where a tag was created.
parent
015ddfe0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab/ci/download/select_jobs.gitlab-ci.yml
+47
-47
47 additions, 47 deletions
.gitlab/ci/download/select_jobs.gitlab-ci.yml
with
47 additions
and
47 deletions
.gitlab/ci/download/select_jobs.gitlab-ci.yml
+
47
−
47
View file @
26a982a9
...
@@ -100,7 +100,6 @@
...
@@ -100,7 +100,6 @@
| map(select(.commit.created_at != null and (.commit.created_at <= $before_date)))
| map(select(.commit.created_at != null and (.commit.created_at <= $before_date)))
' <<<"$DEP_TAGS")
' <<<"$DEP_TAGS")
SELECTED_TAG=""
if [[ $(jq length <<<"$TAGS_BEFORE_DATE") != 0 ]]; then
if [[ $(jq length <<<"$TAGS_BEFORE_DATE") != 0 ]]; then
BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$TAGS_BEFORE_DATE")
BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$TAGS_BEFORE_DATE")
echo "Found release : $BRANCH_TO_PULL. Using it as \$BRANCH_TO_PULL."
echo "Found release : $BRANCH_TO_PULL. Using it as \$BRANCH_TO_PULL."
...
@@ -302,8 +301,7 @@
...
@@ -302,8 +301,7 @@
$DEP_ID=$(Invoke-RestMethod -Uri "$API_URL/users/$USER_ID/projects?search=${DEP_NAME}" -Method Get)[0].id
$DEP_ID=$(Invoke-RestMethod -Uri "$API_URL/users/$USER_ID/projects?search=${DEP_NAME}" -Method Get)[0].id
}
}
Write-Host "DEP_ID = $DEP_ID"
Write-Host "DEP_ID = $DEP_ID"
$DEP_URL="$DEP_API_URL"
$DEP_API_URL="$API_URL/projects/$DEP_ID"
######################################################################################################
######################################################################################################
# Retrieve the branch to pull
# Retrieve the branch to pull
...
@@ -319,55 +317,58 @@
...
@@ -319,55 +317,58 @@
$BRANCH_TO_PULL=$DEFAULT_BRANCH # default branch to pull
$BRANCH_TO_PULL=$DEFAULT_BRANCH # default branch to pull
Write-Host "Choosing a branch to pull dependending if we are in a Non draft merge request or not."
Write-Host "Choosing a branch to pull dependending if we are in a Non draft merge request or not."
Write-Host "CI_MERGE_REQUEST_TITLE = $CI_MERGE_REQUEST_TITLE"
Write-Host "CI_MERGE_REQUEST_TITLE = $CI_MERGE_REQUEST_TITLE"
Write-Host "CI_COMMIT_TAG = $CI_COMMIT_TAG"
Write-Host "CI_MERGE_REQUEST_TITLE = $CI_MERGE_REQUEST_TITLE"
################################
################################
# CASE NON DRAFT MERGE REQUEST
# CASE NON DRAFT MERGE REQUEST
if ( "$CI_MERGE_REQUEST_ID" -and ! ("$CI_MERGE_REQUEST_TITLE" -match 'Draft.*') ) { # case we are in a merge request
if ( "$CI_MERGE_REQUEST_ID" -and ! ("$CI_MERGE_REQUEST_TITLE" -match 'Draft.*') ) { # case we are in a merge request
# If the MR is not in draft: pulling from target branch (if exists otherwise dev)
# If the MR is not in draft: pulling from target branch (if exists otherwise dev)
Write-Host "Retrieving branches of $DEP_NAME $DEP_API_URL/repository/branches?per_page=100"
Write-Host "Retrieving branches of $DEP_NAME $DEP_API_URL/repository/branches?per_page=100"
$DEP_BRANCHES=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/branches?per_page=100" -Method Get) | Select-Object name)
$DEP_BRANCHES=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/branches?per_page=100" -Method Get) | Select-Object name)
Write-Host "Found $($DEP_BRANCHES.Count) branches."
Write-Host "Found $($DEP_BRANCHES.Count) branches."
Write-Host "$($DEP_BRANCHES | Out-String)"
Write-Host "$($DEP_BRANCHES | Out-String)"
Write-Host "NON DRAFT MERGE REQUEST Pipeline detected : Pulling from CI_MERGE_REQUEST_TARGET_BRANCH_NAME : $CI_MERGE_REQUEST_TARGET_BRANCH_NAME."
Write-Host "NON DRAFT MERGE REQUEST Pipeline detected : Pulling from CI_MERGE_REQUEST_TARGET_BRANCH_NAME : $CI_MERGE_REQUEST_TARGET_BRANCH_NAME."
Write-Host "Checking if CI_MERGE_REQUEST_TARGET_BRANCH_NAME "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" branch exists, otherwise pull from default."
Write-Host "Checking if CI_MERGE_REQUEST_TARGET_BRANCH_NAME "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" branch exists, otherwise pull from default."
$FILTERED_BRANCHES=@($DEP_BRANCHES | Where-Object { $_.name -eq "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"})
$FILTERED_BRANCHES=@($DEP_BRANCHES | Where-Object { $_.name -eq "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"})
if ( ($FILTERED_BRANCHES.Count) -gt 0){
Write-Host "Found MR target branch in $DEP_NAME."
if ( ($FILTERED_BRANCHES.Count) -gt 0){
$BRANCH_TO_PULL=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
Write-Host "Found MR target branch in $DEP_NAME."
Write-Host "Pulling from merge request target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
$BRANCH_TO_PULL=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
} else {
Write-Host "Pulling from merge request target branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
Write-Host "Branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME not found on repo $DEP_NAME."
} else {
Write-Host "Pulling from default branch."
Write-Host "Branch $CI_MERGE_REQUEST_TARGET_BRANCH_NAME not found on repo $DEP_NAME."
}
Write-Host "Pulling from default branch."
}
######################################
######################################
# CASE WHERE A COMMIT TAG IS CREATED
# CASE WHERE A COMMIT TAG IS CREATED
} else if ( "$CI_COMMIT_TAG" ) {
} elseif ( "$CI_COMMIT_TAG" ) {
$REPO_CURR_TAG_DATE=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags/$CI_COMMIT_TAG" -Method Get) | Select-Object commit.created_at)
Write-Host "Rretrieving the creation_date of the commit the tag has been created from $DEP_API_URL/repository/tags/$CI_COMMIT_TAG"
# PROJECT_CURR_TAG_DATE=$(jq '.commit.created_at' <<<$(curl -s "$API_URL/projects/$CI_PROJECT_ID/repository/tags/$CI_COMMIT_TAG"))
$REPO_CURR_TAG_DATE=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags/$CI_COMMIT_TAG" -Method Get).commit.created_at)
Write-Host "REPO_CURR_TAG_DATE = $REPO_CURR_TAG_DATE"
Write-Host "Looking for latest release in $DEP_NAME before $CI_COMMIT_TAG was released on project $CI_PROJECT_NAME."
Write-Host "Looking for latest release in $DEP_NAME before $CI_COMMIT_TAG was released on project $CI_PROJECT_NAME."
$DEP_TAGS_BEFORE_DATE=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) |
Write-Host "Retrieving repo tags from $DEP_API_URL/repository/tags?per_page=100"
Sort-Object -Property commit.created_at -Descending |
$DEP_TAGS=$($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) |
Where-Object { $_.commit.created_at -eq "$CI_COMMIT_REF_NAME"}
Sort-Object -Property commit.created_at -Descending)
$DEP_TAGS_BEFORE_DATE=$()
Write-Host "DEP_TAGS = $DEP_TAGS"
# TAGS_BEFORE_DATE=$(jq --slurp --arg before_date "$PROJECT_CURR_TAG_DATE" '
# .[]
Write-Host "Looking for latest release in $DEP_NAME before $CI_COMMIT_TAG was released on project $CI_PROJECT_NAME."
# | map(select(.commit.created_at != null and (.commit.created_at <= $before_date)))
Write-Host "Retrieving repo tags from $DEP_API_URL/repository/tags?per_page=100"
# ' <<<"$DEP_TAGS")
$DEP_TAGS_BEFORE_DATE=$($DEP_TAGS |
Where-Object { $_.commit.created_at -le "$REPO_CURR_TAG_DATE"})
# SELECTED_TAG=""
Write-Host "Found $($DEP_TAGS_BEFORE_DATE.Count) tags pre-dating release $CI_COMMIT_TAG."
# if [[ $(jq length <<<"$TAGS_BEFORE_DATE") != 0 ]]; then
$DEP_TAGS_BEFORE_DATE | Select-Object name | Out-String
# BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$TAGS_BEFORE_DATE")
# echo "Found release : $BRANCH_TO_PULL. Using it as \$BRANCH_TO_PULL."
# else
# echo "Found no release predating $CI_PROJECT_NAME $CI_COMMIT_TAG's date : $CI_COMMIT_TAG."
# echo "Retrieving latest repo tag."
# BRANCH_TO_PULL=$(jq -r '.[0].name' <<<"$DEP_TAGS")
# echo "\$BRANCH_TO_PULL = $BRANCH_TO_PULL"
# fi
if ( $($DEP_TAGS_BEFORE_DATE.Count) -ne 0) {
$BRANCH_TO_PULL=$DEP_TAGS_BEFORE_DATE[0].name
Write-Host "Found release : $BRANCH_TO_PULL. Using it as BRANCH_TO_PULL."
}
else {
Write-Host "Found no release predating $CI_PROJECT_NAME $CI_COMMIT_TAG's date : $CI_COMMIT_TAG."
Write-Host "Retrieving latest repo tag."
BRANCH_TO_PULL=$DEP_TAGS[0].name
Write-Host "\$BRANCH_TO_PULL = $BRANCH_TO_PULL"
}
###########################################
###########################################
# CASE CASUAL COMMIT or Draft MR PIPELINE
# CASE CASUAL COMMIT or Draft MR PIPELINE
} else {
} else {
...
@@ -391,11 +392,10 @@
...
@@ -391,11 +392,10 @@
#######################################################
#######################################################
# Retrieve JOB ID
# Retrieve JOB ID
## Prepare pipelines to parse to retrieve the jobs of each pipelines
## Prepare pipelines to parse to retrieve the jobs of each pipelines
Write-Host "*************************************************************************"
Write-Host "*************************************************************************"
Write-Host "*************************************************************************"
Write-Host "*************************************************************************"
Write-Host "**"
Write-Host "**"
Write-Host "** RETRIEVING LATEST SUCCESSFUL PIPELINES IN
GIVEN BRANCH
"
Write-Host "** RETRIEVING LATEST SUCCESSFUL PIPELINES IN
REF
"
Write-Host "** $BRANCH_TO_PULL"
Write-Host "** $BRANCH_TO_PULL"
Write-Host "**"
Write-Host "**"
Write-Host "*************************************************************************"
Write-Host "*************************************************************************"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment