Skip to content

Commit

Permalink
fetch .git/ directory from GitHub since Jenkins doesn't stash it
Browse files Browse the repository at this point in the history
  • Loading branch information
bpholt committed Sep 15, 2023
1 parent 3b52cd6 commit d8b69d9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
set -o errexit
IFS=$'\n\t'

# the .git folder and .gitignore file are not stashed by Jenkins, so we need to fetch them
git init
git remote add origin "$GIT_URL"
git fetch origin

set +o nounset
if [ -z ${TAG_NAME+x} ]; then
TARGET_COMMIT="${GIT_COMMIT}"
else
TARGET_COMMIT="${TAG_NAME}"
fi
set -o nounset
readonly TARGET_COMMIT

# use `git checkout --force` here because we expect the working directory not to be
# empty at this point. Jenkins unstashed everything from the previous stage into the
# working directory; we want to keep the build artifacts (i.e. everything in the
# various target/ directories) but update the files committed to git to the version
# currently being built.
git checkout --force "${TARGET_COMMIT}"

# nvm is a bash function, so fake command echoing for nvm commands to reduce noise
echo "+ . ${NVM_DIR}/nvm.sh --no-use"
. "${NVM_DIR}/nvm.sh" --no-use
Expand Down
4 changes: 2 additions & 2 deletions project/ServerlessDeployPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object ServerlessDeployPlugin extends AutoPlugin {
if (taggedVersion.value.exists(_.toString == version.value)) {
if (deployProcess.! == 0) Success
else throw new IllegalStateException("Serverless returned a non-zero exit code. Please check the logs for more information.")
} else SkippedBecauseVersionIsNotLatestTag
} else SkippedBecauseVersionIsNotLatestTag(version.value, taggedVersion.value)
}.evaluated
)

Expand All @@ -59,5 +59,5 @@ object ServerlessDeployPlugin extends AutoPlugin {

sealed trait DeployOutcome // no failed outcome because we just throw an exception in that case
case object Success extends DeployOutcome
case object SkippedBecauseVersionIsNotLatestTag extends DeployOutcome
case class SkippedBecauseVersionIsNotLatestTag(version: String, taggedVersion: Option[Version]) extends DeployOutcome
}

0 comments on commit d8b69d9

Please sign in to comment.