Skip to content

Commit

Permalink
Change DSL nightly call to use GITHUB_TOKEN
Browse files Browse the repository at this point in the history
  • Loading branch information
j-rivero committed Nov 14, 2024
1 parent b2502b0 commit 85ea888
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
19 changes: 19 additions & 0 deletions jenkins-scripts/dsl/_configs_/GitHubCredentials.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package _configs_

import javaposse.jobdsl.dsl.Job

class GitHubCredentials
{
static void createOsrfbuildToken(Job job)
{
job.with
{
wrappers {
// credential name needs to be in sync with provision code at infra/osrf-chef repo
credentialsBinding {
string('GITHUB_TOKEN', 'osrfbuild-token')
}
}
}
}
}
13 changes: 9 additions & 4 deletions jenkins-scripts/dsl/ignition_collection.dsl
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ nightly_collection = gz_collections_yaml.collections

def nightly_scheduler_job = job("ignition-${gz_nightly}-nightly-scheduler")
OSRFUNIXBase.create(nightly_scheduler_job)
GitHubCredentials.createOsrfbuildToken(nightly_scheduler_job)

nightly_scheduler_job.with
{
Expand Down Expand Up @@ -190,8 +191,6 @@ nightly_scheduler_job.with
steps {
shell("""\
#!/bin/bash -xe
set +x # keep password secret
PASS=\$(cat \$HOME/build_pass)

dry_run_str=""
if \$DRY_RUN; then
Expand Down Expand Up @@ -239,9 +238,15 @@ nightly_scheduler_job.with
src_branch="main"
fi

set +x # safeguard keep password secret
echo "releasing \${n} (from branch \${src_branch})"
python3 ./scripts/release.py \${dry_run_str} "\${n}" nightly "\${PASS}" --release-repo-branch main --nightly-src-branch \${src_branch} --upload-to-repo nightly > log || echo "MARK_AS_UNSTABLE"
echo " - done"
# TODO: migrate the crendential to use USERNAME and PASSWORD instead only the token
# to avoid the hardcode of osrfbuild user here.
python3 ./scripts/release.py \${dry_run_str} "\${n}" nightly \
--auth 'osrfbuild:\${GITHUB_TOKEN}' \
--release-repo-branch main --nightly-src-branch \${src_branch} --upload-to-repo nightly > log || echo "MARK_AS_UNSTABLE"
set -e
echo " - done (log is available)"
done

""".stripIndent())
Expand Down

0 comments on commit 85ea888

Please sign in to comment.